Skip to content

WorkerConfiguration

blehnen edited this page Nov 10, 2026 · 8 revisions

Worker Configuration

The worker configuration controls how many workers process work and how the workers respond to stop requests.

For Sync queues, the worker handles both the de-queue of the work and the processing.

For the Async queues, the worker de-queues items but passes the processing to another thread. Async queues are expected to use only 1 worker, but you can use multiple workers. You might need this if the tasks are very short-lived and the transport cannot dequeue quickly enough to keep the task factory at full capacity.

The worker count property sets how many threads de-queue and process work.

queue.Configuration.Worker.WorkerCount = 4;

You can tell the queue to use a single worker to poll the transport for new work. The other workers are woken up when work is found.

NOTE: This setting has little or no effect on transports that do not require polling. For instance, the Redis transport notifies workers of new work without polling.

queue.Configuration.Worker.SingleWorkerWhenNoWorkFound = true;

This setting controls how long the queue waits after it issues a cancel request. After this time expires, the queue waits until all worker threads complete.

queue.Configuration.Worker.TimeToWaitForWorkersToCancel = TimeSpan.FromSeconds(10);

This setting controls how long the queue waits, after it is told to stop, before it issues a cancel request. When the stop request is issued, workers stop de-queuing. After this time limit is reached, the queue triggers the cancel token, which tells user code to stop or abort its work.

queue.Configuration.Worker.TimeToWaitForWorkersToStop = TimeSpan.FromSeconds(10);

Clone this wiki locally