Class EventDrivenWorker
Worker which controlled by Eco.Core.Utils.Threading.EventDrivenWorker.autoResetEvent. It will wait until Eco.Core.Utils.Threading.EventDrivenWorker.autoResetEvent set before every call to DoRepeatableWork(CancellationToken).
Implements
Inherited Members
Namespace: Eco.Core.Utils.Threading
Assembly: Eco.Core.dll
Syntax
public class EventDrivenWorker : RepeatableWorkerBase, IWorker
Constructors
EventDrivenWorker(Action, Boolean)
Initializes a new instance of the EventDrivenWorker class with infinite timeout between events.
Declaration
public EventDrivenWorker(Action doWork, bool initialEventState = true)
Parameters
Type | Name | Description |
---|---|---|
System.Action | doWork | |
System.Boolean | initialEventState |
EventDrivenWorker(Func<Int32>, Boolean)
Initializes a new instance of the EventDrivenWorker class with timeout between events defined by return value of repeatableAction
function in milliseconds.
Declaration
public EventDrivenWorker(Func<int> repeatableAction, bool initialEventState = true)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Int32> | repeatableAction | |
System.Boolean | initialEventState |
EventDrivenWorker(Func<CancellationToken, Task<Int32>>, Boolean)
Initializes a new instance of the EventDrivenWorker class with infinite timeout between events.
Declaration
public EventDrivenWorker(Func<CancellationToken, Task<int>> repeatableAction, bool initialEventState = true)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<System.Int32>> | repeatableAction | |
System.Boolean | initialEventState |
EventDrivenWorker(AutoResetEvent, Action)
Initializes a new instance of the EventDrivenWorker class with infinite timeout between events.
autoResetEvent
should be set for initial doWork
execution on Start().
Declaration
public EventDrivenWorker(AutoResetEvent autoResetEvent, Action doWork)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.AutoResetEvent | autoResetEvent | |
System.Action | doWork |
EventDrivenWorker(AutoResetEvent, Func<Int32>)
Initializes a new instance of the EventDrivenWorker class with timeout between events defined by return value of repeatableAction
function in milliseconds.
autoResetEvent
should be set for initial repeatableAction
execution on Start().
Declaration
public EventDrivenWorker(AutoResetEvent autoResetEvent, Func<int> repeatableAction)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.AutoResetEvent | autoResetEvent | |
System.Func<System.Int32> | repeatableAction |
EventDrivenWorker(AutoResetEvent, Func<CancellationToken, Task<Int32>>)
Initializes a new instance of the EventDrivenWorker class with infinite timeout between events.
autoResetEvent
should be set for initial repeatableAction
execution on Start().
Declaration
public EventDrivenWorker(AutoResetEvent autoResetEvent, Func<CancellationToken, Task<int>> repeatableAction)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.AutoResetEvent | autoResetEvent | |
System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<System.Int32>> | repeatableAction |
Methods
DoRepeatableWork(CancellationToken)
Performs repeatable work, may be cancelled with token
.
Declaration
protected override Task DoRepeatableWork(CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
SetEvent()
Declaration
public void SetEvent()