Partager via


CurrentScheduler::Detach Method

Detaches the current scheduler from the calling context and restores the previously attached scheduler as the current scheduler, if one exists. After this method returns, the calling context is then managed by the scheduler that was previously attached to the context using either the CurrentScheduler::Create or Scheduler::Attach method.

static void __cdecl Detach();

Remarks

The Detach method implicitly removes a reference count from the scheduler.

If there is no scheduler attached to the calling context, calling this method will result in a scheduler_not_attached exception being thrown.

Calling this method from a context that is internal to and managed by a scheduler, or a context that was attached using a method other than the Scheduler::Attach or CurrentScheduler::Create methods, will result in an improper_scheduler_detach exception being thrown.

Requirements

Header: concrt.h

Namespace: concurrency

See Also

Reference

CurrentScheduler Class

Scheduler::Attach Method

CurrentScheduler::Create Method