-
Notifications
You must be signed in to change notification settings - Fork 14
ConsumerAsyncWorkGroup
The async queue allows you limit the threads used in the task scheduler. This is done by creating a workgroup on the scheduler, and then passing that workgroup to the queue when you create it.
Note this does not reserve threads; it prevents a queue from using more than X number of threads in the scheduler. For instance, you may have very long running tasks. You might want those taks to only execute one at a time to free up resources for shorter running tasks.
- Creating workgroup
var group = taskScheduler.AddWorkGroup("workGroupName", 1, 1);
The above example creates a workgroup with a max concurrency level of 1 and a max queue size of 1. Note that the queue size param will not increase the scheduler queue size. If you specify a vaule and the scheduler has a max of 0, no in memory queue will be used.
- Assigning workgroup to a queue
To assign the workgroup to the queue, pass it in when creating the queue.
var queue = queueContainer.CreateConsumerQueueScheduler(queueConnection, taskFactory, group);
This queue will only be able to use a max of one thread in the scheduler, and can have at most 1 item queued in the scheduler.
For any issues please use the GitHub issues