TaskScheduler Class

TaskScheduler Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Represents an object that handles the low-level work of queuing tasks onto threads.


Namespace:  System.Threading.Tasks
Assembly:  mscorlib (in mscorlib.dll)

public abstract class TaskScheduler

The TaskScheduler type exposes the following members.

Protected methodTaskSchedulerInitializes the TaskScheduler.

Public propertyStatic memberCurrentGets the TaskScheduler associated with the currently executing task.
Public propertyStatic memberDefaultGets the default TaskScheduler instance that is provided by the .NET Framework.
Public propertyIdGets the unique ID for this TaskScheduler.
Public propertyMaximumConcurrencyLevelIndicates the maximum concurrency level this TaskScheduler is able to support.

Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic memberFromCurrentSynchronizationContextCreates a TaskScheduler associated with the current System.Threading.SynchronizationContext.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Protected methodGetScheduledTasksSecurity Critical. For debugger support only, generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodQueueTaskSecurity Critical. Queues a Task to the scheduler.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodTryDequeueSecurity Critical. Attempts to dequeue a Task that was previously queued to this scheduler.
Protected methodTryExecuteTaskSecurity Critical. Attempts to execute the provided Task on this scheduler.
Protected methodTryExecuteTaskInlineSecurity Critical. Determines whether the provided Task can be executed synchronously in this call, and if it can, executes it.

Public eventStatic memberUnobservedTaskExceptionOccurs when a faulted Task's unobserved exception is about to trigger exception escalation policy, which, by default, would terminate the process.

TaskScheduler acts as the extension point for all pluggable scheduling logic. This includes mechanisms such as how to schedule a task for execution, and how scheduled tasks should be exposed to debuggers.

For more information and code examples, see [638f8ea5-21db-47a2-a934-86e1e961bf65].

Several sample task schedulers are available on Code Gallery: Samples for Parallel Programming with the .NET Framework 4.

Windows Phone OS

Supported in: 8.1, 8.0

All members of the abstract TaskScheduler type are thread-safe and may be used from multiple threads concurrently.

© 2018 Microsoft