다음을 통해 공유


TaskScheduler Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

Inheritance Hierarchy

System.Object
  System.Threading.Tasks.TaskScheduler

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

Syntax

'Declaration
<DebuggerDisplayAttribute("Id={Id}")> _
Public MustInherit Class TaskScheduler
[DebuggerDisplayAttribute("Id={Id}")]
public abstract class TaskScheduler

The TaskScheduler type exposes the following members.

Constructors

  Name Description
Protected method TaskScheduler Initializes the TaskScheduler.

Top

Properties

  Name Description
Public propertyStatic member Current Gets the TaskScheduler associated with the currently executing task.
Public propertyStatic 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

Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows 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 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 Security Critical. 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 Security Critical. Queues a Task to the scheduler.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Protected method TryDequeue Security Critical. Attempts to dequeue a Task that was previously queued to this scheduler.
Protected method TryExecuteTask Security Critical. Attempts to execute the provided Task on this scheduler.
Protected method TryExecuteTaskInline Security Critical. Determines whether the provided Task can be executed synchronously in this call, and if it can, executes it.

Top

Events

  Name Description
Public eventStatic 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

Remarks

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.

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

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