Interface IWorker
Defines a standard API to control background application workers.
Namespace: Swan.Threading
Syntax
public interface IWorker
Properties
IsDisposed
Gets a value indicating whether this instance is disposed.
Declaration
bool IsDisposed { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
IsDisposing
Gets a value indicating whether this instance is currently being disposed.
Declaration
bool IsDisposing { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
Name
Gets the name identifier of this worker.
Declaration
string Name { get; }
Property Value
Type | Description |
---|---|
String |
Period
Gets or sets the time interval used to execute cycles.
Declaration
TimeSpan Period { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
WorkerState
Gets the current state of the worker.
Declaration
WorkerState WorkerState { get; }
Property Value
Type | Description |
---|---|
WorkerState |
Methods
PauseAsync()
Pauses execution of worker cycles.
Declaration
Task<WorkerState> PauseAsync()
Returns
Type | Description |
---|---|
Task<WorkerState> | The awaitable task. |
ResumeAsync()
Resumes execution of worker cycles.
Declaration
Task<WorkerState> ResumeAsync()
Returns
Type | Description |
---|---|
Task<WorkerState> | The awaitable task. |
StartAsync()
Starts execution of worker cycles.
Declaration
Task<WorkerState> StartAsync()
Returns
Type | Description |
---|---|
Task<WorkerState> | The awaitable task. |
StopAsync()
Permanently stops execution of worker cycles. An interrupt is always sent to the worker. If you wish to stop the worker without interrupting then call the PauseAsync() method, await it, and finally call the StopAsync() method.
Declaration
Task<WorkerState> StopAsync()
Returns
Type | Description |
---|---|
Task<WorkerState> | The awaitable task. |