Class QueuedActionWorkerTask
This class is intended to be the base class for other classes that need to queue actions and execute them on a single thread context. It is generally not used directly in a stand-alone manner.
After constructing a class derived from this class, the derived class must call the Start() method to start the background task. When the derived class is shutting down, it must call the Shutdown() method.
Actions are queued for execution by calling the EnqueueAction() method.
Derived classes can override the DoTimedEvents() methods so that they can do work periodically within the tread context of this class. The DoTimedEvents() method is called each time through the task loop. The maximum period of execution is the WaitIntervalMsec value provided in the constructor.
Inherited Members
Namespace: SipLib.Threading
Assembly: SipLib.dll
Syntax
public class QueuedActionWorkerTask
Constructors
| Edit this page View SourceQueuedActionWorkerTask(int)
Constructor
Declaration
public QueuedActionWorkerTask(int WaitIntervalMsec = 100)
Parameters
Type | Name | Description |
---|---|---|
int | WaitIntervalMsec | Specifies the maximum number of milliseconds that the worker task spends sleeping. The minimum value is 10 msec. There is no maximum value. |
Methods
| Edit this page View SourceDoTimedEvents()
Declaration
protected virtual void DoTimedEvents()
EnqueueWork(Action)
Enqueues an action and signals the background worker task to wake up and dequeue actions from the internal action queue and perform them.
Declaration
protected void EnqueueWork(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | Action to be queued and executed. |
Shutdown()
Causes the background task that executes actions to terminate. The background worker task may not terminate until the action that is currently being executed completes or a maximum of 500 ms elapses.
Declaration
public virtual Task Shutdown()
Returns
Type | Description |
---|---|
Task |
Start()
Starts the backgroud task that executes queued actions.
Declaration
public virtual void Start()