Interface IWorkerThread
Represents a dedicated worker thread that executes queued actions in FIFO order.
public interface IWorkerThread
Properties
CancellationToken
Gets the token canceled when the worker is stopped.
CancellationToken CancellationToken { get; }
Property Value
IsBusy
Gets whether an action is executing or queued.
bool IsBusy { get; }
Property Value
NumOpenActions
Gets the number of actions waiting in the queue.
int NumOpenActions { get; }
Property Value
Methods
ClearOpenCommands()
Removes queued actions that have not started.
void ClearOpenCommands()
ClearOpenCommandsAsync()
Asynchronously acquires the queue lock and removes actions that have not started.
Task ClearOpenCommandsAsync()
Returns
ExecuteCommand(Action)
Queues an action for execution.
void ExecuteCommand(Action action)
Parameters
actionAction
ExecuteCommand(Action, string)
Queues an action with a message used when logging failures.
void ExecuteCommand(Action action, string message)
Parameters
ExecuteCommandAsync(Action)
Asynchronously acquires the queue lock and queues an action.
Task ExecuteCommandAsync(Action action)
Parameters
actionAction
Returns
ExecuteCommandAsync(Action, string)
Asynchronously acquires the queue lock and queues an action with a diagnostic message.
Task ExecuteCommandAsync(Action action, string message)
Parameters
Returns
StopThread(TimeSpan?)
Stops the worker, clears pending actions, and waits for the thread to terminate.
void StopThread(TimeSpan? timeOut = null)
Parameters
timeOutTimeSpan?
Events
IdleEvent
Occurs when the worker enters or leaves the idle state; the argument is true when idle.
event Action<bool> IdleEvent
Event Type
OnDeInitThread
Occurs on the worker thread when it terminates after initialization.
event Action OnDeInitThread
Event Type
OnInitThread
Occurs on the worker thread before its first action executes.
event Action OnInitThread