0 out of 4 rated this helpful - Rate this topic

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)
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true, 
	ExternalThreading = true)]
public abstract class TaskScheduler

The TaskScheduler type exposes the following members.

  Name Description
Protected method TaskScheduler Initializes the TaskScheduler.
Top
  Name Description
Public property Static member Current Gets the TaskScheduler associated with the currently executing task.
Public property Static member Default Gets the default TaskScheduler instance that is provided by the .NET Framework.
Public property Id Gets the unique ID for this TaskScheduler.
Public property MaximumConcurrencyLevel Indicates the maximum concurrency level this TaskScheduler is able to support.
Top
  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Frees all resources associated with this scheduler. (Overrides Object.Finalize().)
Public method Static member FromCurrentSynchronizationContext Creates a TaskScheduler associated with the current System.Threading.SynchronizationContext.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Protected method GetScheduledTasks For debugger support only, generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method QueueTask Queues a Task to the scheduler.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Protected method TryDequeue Attempts to dequeue a Task that was previously queued to this scheduler.
Protected method TryExecuteTask Attempts to execute the provided Task on this scheduler.
Protected method TryExecuteTaskInline Determines whether the provided Task can be executed synchronously in this call, and if it can, executes it.
Top
  Name Description
Public event Static member UnobservedTaskException Occurs 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.

Note Note

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.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ