Compartilhar via


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.

virtual void Attach() =0;

Remarks

Attaching a scheduler implicitly places a reference on the scheduler.

At some point in the future, you must call the CurrentScheduler::Detach method in order to allow the scheduler to shut down.

If this method is called from a context that is already attached to a different scheduler, the existing scheduler is remembered as the previous scheduler, and the newly created scheduler becomes the current scheduler. When you call the CurrentScheduler::Detach method at a later point, the previous scheduler is restored as the current scheduler.

This method will throw an improper_scheduler_attach exception if this scheduler is the current scheduler of the calling context.

Requirements

Header: concrt.h

Namespace: concurrency

See Also

Reference

Scheduler Class

CurrentScheduler::Detach Method