Class DistributedQueueTaskScheduler
A task scheduler that distributes tasks across multiple threads or processes. Allows for controlled execution of tasks with a specified maximum concurrency level.
public class DistributedQueueTaskScheduler : TaskScheduler, IDisposable
- Inheritance
-
DistributedQueueTaskScheduler
- Implements
- Inherited Members
- Extension Methods
Constructors
DistributedQueueTaskScheduler(DistributedQueueTaskStarter, int, int)
Initializes a new instance of the DistributedQueueTaskScheduler class.
public DistributedQueueTaskScheduler(DistributedQueueTaskStarter starter, int maxIdlingTaskNum, int maxWorkingTaskNum)
Parameters
starter
DistributedQueueTaskStarterThe task starter responsible for distributing tasks.
maxIdlingTaskNum
intThe maximum number of tasks that can be queued.
maxWorkingTaskNum
intThe maximum number of tasks that can be executed concurrently.
Properties
MaxWorkingTaskNum
Gets the maximum number of tasks that can be executed concurrently.
public int MaxWorkingTaskNum { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the DistributedQueueTaskScheduler and optionally releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposing
booltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
GetScheduledTasks()
Gets the tasks currently scheduled for execution.
protected override IEnumerable<Task> GetScheduledTasks()
Returns
- IEnumerable<Task>
An enumerable of the tasks currently scheduled.
QueueTask(Task)
Queues a task to the scheduler.
protected override void QueueTask(Task task)
Parameters
task
TaskThe task to be queued.
TryExecuteTaskInline(Task, bool)
Tries to execute a task synchronously on the current thread.
protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
Parameters
task
TaskThe task to be executed.
taskWasPreviouslyQueued
boolWhether the task was previously queued to the scheduler.
Returns
- bool
true if the task was successfully executed; otherwise, false.
WaitAll()
Waits for all queued tasks to complete.
public void WaitAll()
Events
Ending
Event that is raised when a worker thread ends processing tasks.
public event Action Ending
Event Type
Starting
Event that is raised when a worker thread starts processing tasks.
public event Action Starting