Interface IWorkerPlugin
Namespace: Eco.Core.Plugins.Interfaces
Assembly: Eco.Core.dll
Syntax
public interface IWorkerPlugin : IServerPlugin
Methods
DoWork(CancellationToken)
Performs one unit of work. There no delay between DoWork(CancellationToken) calls, it works pretty much like one iteration of loop.
Usually you need to maintain delay between calls with System.Threading.Tasks.Task.Delay(System.Int32) or Eco.Core.Utils.Async.SingleObjectWaiter.WaitAsync(System.Threading.WaitHandle,System.Int64,System.Threading.CancellationToken) or other async wait methods to only perform work as often as required.
Try to avoid idle loops and do work only when required. In some cases it may be preferred to use PeriodicWorkerFactory instead for more flexible worker creation.
Work may be interrupted between DoWork(CancellationToken) calls or provided token
can be used to check if work should be cancelled within DoWork(CancellationToken).
Declaration
Task DoWork(CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | token | cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |