TaskScheduler Class

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

System.Object
  System.Threading.Tasks.TaskScheduler

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

[<AbstractClass>]
type TaskScheduler =  class end

The TaskScheduler type exposes the following members.

  NameDescription
Protected methodSupported by Portable Class LibraryTaskSchedulerInitializes the TaskScheduler.
Top

  NameDescription
Public propertyStatic memberSupported by Portable Class LibraryCurrentGets the TaskScheduler associated with the currently executing task.
Public propertyStatic memberSupported by Portable Class LibraryDefaultGets the default TaskScheduler instance that is provided by the .NET Framework.
Public propertySupported by Portable Class LibraryIdGets the unique ID for this TaskScheduler.
Public propertySupported by Portable Class LibraryMaximumConcurrencyLevelIndicates the maximum concurrency level this TaskScheduler is able to support.
Top

  NameDescription
Public methodSupported by Portable Class LibraryEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by Portable Class LibraryFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)

In .NET Framework Client Profile, this member is overridden by Finalize().


In Portable Class Library, this member is overridden by Finalize().
Public methodStatic memberSupported by Portable Class LibraryFromCurrentSynchronizationContextCreates a TaskScheduler associated with the current System.Threading.SynchronizationContext.
Public methodSupported by Portable Class LibraryGetHashCodeServes as the default hash function. (Inherited from Object.)
Protected methodSupported by Portable Class LibraryGetScheduledTasksFor debugger support only, generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.
Public methodSupported by Portable Class LibraryGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Portable Class LibraryMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported by Portable Class LibraryQueueTaskQueues a Task to the scheduler.
Public methodSupported by Portable Class LibraryToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodSupported by Portable Class LibraryTryDequeueAttempts to dequeue a Task that was previously queued to this scheduler.
Protected methodSupported by Portable Class LibraryTryExecuteTaskAttempts to execute the provided Task on this scheduler.
Protected methodSupported by Portable Class LibraryTryExecuteTaskInlineDetermines whether the provided Task can be executed synchronously in this call, and if it can, executes it.
Top

  NameDescription
Public eventStatic memberSupported by Portable Class LibraryUnobservedTaskExceptionOccurs when a faulted task's unobserved exception is about to trigger exception escalation policy, which, by default, would terminate the process.
Top

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 Task Schedulers.

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

The following example is taken from the Samples for Parallel Programming with the .NET Framework 4 on the MSDN Code Gallery Web site.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft