Class PriorityBasedTaskScheduler
A task scheduler that executes tasks with a specified thread priority.
public class PriorityBasedTaskScheduler : TaskScheduler
- Inheritance
-
PriorityBasedTaskScheduler
- Inherited Members
- Extension Methods
Constructors
PriorityBasedTaskScheduler(ThreadPriority)
Initializes a new instance.
public PriorityBasedTaskScheduler(ThreadPriority threadPriority)
Parameters
threadPriorityThreadPriorityThe thread priority for executing tasks.
Properties
MaxDegreeOfParallelism
Max Degree Of Parallelism. Set special value 0 for no limiting.
public int MaxDegreeOfParallelism { get; set; }
Property Value
ThreadPriority
Gets or sets the thread priority for executing tasks.
public ThreadPriority ThreadPriority { get; set; }
Property Value
Methods
GetScheduledTasks()
For debugger support only, generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.
protected override IEnumerable<Task> GetScheduledTasks()
Returns
- IEnumerable<Task>
An enumerable that allows a debugger to traverse the tasks currently queued to this scheduler.
Exceptions
- NotSupportedException
This scheduler is unable to generate a list of queued tasks at this time.
QueueTask(Task)
Queues a Task to the scheduler.
protected override void QueueTask(Task task)
Parameters
Exceptions
- ArgumentNullException
The
taskargument is null.
TryExecuteTaskInline(Task, bool)
Determines whether the provided Task can be executed synchronously in this call, and if it can, executes it.
protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
Parameters
taskTaskThe Task to be executed.
taskWasPreviouslyQueuedboolA Boolean denoting whether or not task has previously been queued. If this parameter is True, then the task may have been previously queued (scheduled); if False, then the task is known not to have been queued, and this call is being made in order to execute the task inline without queuing it.
Returns
- bool
A Boolean value indicating whether the task was executed inline.
Exceptions
- ArgumentNullException
The
taskargument is null.- InvalidOperationException
The
taskwas already executed.