Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Scheduler Class

Represents an abstraction for a Concurrency Runtime scheduler.

class Scheduler;

Protected Constructors



Scheduler::Scheduler Constructor

An object of the Scheduler class can only created using factory methods, or implicitly.

Scheduler::~Scheduler Destructor

An object of the Scheduler class is implicitly destroyed when all external references to it cease to exist.

Public Methods



Scheduler::Attach Method

Attaches the scheduler to the calling context. After this method returns, the calling context is managed by the scheduler and the scheduler becomes the current scheduler.

Scheduler::Create Method

Creates a new scheduler whose behavior is described by the _Policy parameter, places an initial reference on the scheduler, and returns a pointer to it.

Scheduler::CreateScheduleGroup Method

Creates a new schedule group within the scheduler.

Scheduler::GetNumberOfVirtualProcessors Method

Returns the current number of virtual processors for the scheduler.

Scheduler::GetPolicy Method

Returns a copy of the policy that the scheduler was created with.

Scheduler::Id Method

Returns a unique identifier for the scheduler.

Scheduler::Reference Method

Increments the scheduler's reference count.

Scheduler::RegisterShutdownEvent Method

Causes the Windows event handle passed in the _Event parameter to be signaled when the scheduler shuts down and destroys itself. At the time the event is signaled, all work that had been scheduled to the scheduler is complete. Multiple shutdown events may be registered through this method.

Scheduler::Release Method

Decrements this scheduler's reference count.

Scheduler::ResetDefaultSchedulerPolicy Method

Resets the default scheduler policy to the runtime's default. The next time a default scheduler is created, it will use the runtime's default policy settings.

Scheduler::ScheduleTask Method

Schedules a light-weight task within the scheduler. The light-weight task will be placed in a schedule group of the runtime's choosing.

Scheduler::SetDefaultSchedulerPolicy Method

Allows a user defined policy to be used to create the default scheduler. This method may only be called when no default scheduler exists within the process. Once a default policy has been set, it remains in effect until the next valid call to either the SetDefaultSchedulerPolicy or the ResetDefaultSchedulerPolicy method.

The Concurrency Runtime scheduler uses execution contexts, which map to the operating system's execution contexts, such as a thread or a UMS thread, to execute the work queued to it by your application. At any time, the concurrency level of a scheduler is equal to the number of virtual processor granted to it by the Resource Manager. A virtual processor is an abstraction for a processing resource and maps to a hardware thread on the underlying system. Only a single scheduler context may execute on a virtual processor at a given time.

The Concurrency Runtime will create a default scheduler per process to execute parallel work. In addition you may create your own scheduler instances and manipulate it using this class.

Header: concrt.h

Namespace: Concurrency

Community Additions

© 2017 Microsoft