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
Assembly:  mscorlib (in mscorlib.dll)

[<AbstractClass>]
[<PermissionSetAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)>]
[<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true, 
    ExternalThreading = true)>]
type TaskScheduler =  class end

The TaskScheduler type exposes the following members.

  NameDescription
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsTaskSchedulerInitializes the TaskScheduler.
Top

  NameDescription
Public propertyStatic memberSupported by Portable Class LibrarySupported in .NET for Windows Store appsCurrentGets the TaskScheduler associated with the currently executing task.
Public propertyStatic memberSupported by Portable Class LibrarySupported in .NET for Windows Store appsDefaultGets the default TaskScheduler instance that is provided by the .NET Framework.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsIdGets the unique ID for this TaskScheduler.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsMaximumConcurrencyLevelIndicates the maximum concurrency level this TaskScheduler is able to support.
Top

  NameDescription
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsEquals(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 LibrarySupported in .NET for Windows Store appsFromCurrentSynchronizationContextCreates a TaskScheduler associated with the current System.Threading.SynchronizationContext.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetScheduledTasksFor debugger support only, generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsQueueTaskQueues a Task to the scheduler.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsTryDequeueAttempts to dequeue a Task that was previously queued to this scheduler.
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsTryExecuteTaskAttempts to execute the provided Task on this scheduler.
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsTryExecuteTaskInlineDetermines 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 LibrarySupported in .NET for Windows Store appsUnobservedTaskExceptionOccurs 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.

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Synchronization | ExternalThreading. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

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.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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:
© 2014 Microsoft