TaskScheduler Class

TaskScheduler Class

.NET Framework (current version)
 

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

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

System::Object
  System.Threading.Tasks::TaskScheduler

[HostProtectionAttribute(SecurityAction::LinkDemand, Synchronization = true, 
	ExternalThreading = true)]
[PermissionSetAttribute(SecurityAction::InheritanceDemand, Unrestricted = true)]
public ref class TaskScheduler abstract 

NameDescription
System_CAPS_protmethodTaskScheduler()

Initializes the TaskScheduler.

NameDescription
System_CAPS_pubpropertySystem_CAPS_staticCurrent

Gets the TaskScheduler associated with the currently executing task.

System_CAPS_pubpropertySystem_CAPS_staticDefault

Gets the default TaskScheduler instance that is provided by the .NET Framework.

System_CAPS_pubpropertyId

Gets the unique ID for this TaskScheduler.

System_CAPS_pubpropertyMaximumConcurrencyLevel

Indicates the maximum concurrency level this TaskScheduler is able to support.

NameDescription
System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticFromCurrentSynchronizationContext()

Creates a TaskScheduler associated with the current System.Threading::SynchronizationContext.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_protmethodGetScheduledTasks()

For debugger support only, generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodQueueTask(Task^)

Queues a Task to the scheduler.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_protmethodTryDequeue(Task^)

Attempts to dequeue a Task that was previously queued to this scheduler.

System_CAPS_protmethodTryExecuteTask(Task^)

Attempts to execute the provided Task on this scheduler.

System_CAPS_protmethodTryExecuteTaskInline(Task^, Boolean)

Determines whether the provided Task can be executed synchronously in this call, and if it can, executes it.

NameDescription
System_CAPS_pubeventSystem_CAPS_staticUnobservedTaskException

Occurs 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 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.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 5.0
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1

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

Return to top
Show:
© 2016 Microsoft