Compartir a través de


Context::Block Method

Blocks the current context.

static void __cdecl Block();

Remarks

This method will result in the process' default scheduler being created and/or attached to the calling context if there is no scheduler currently associated with the calling context.

If the calling context is running on a virtual processor, the virtual processor will find another runnable context to execute or can potentially create a new one.

After the Block method has been called or will be called, you must pair it with a call to the Unblock method from another execution context in order for it to run again. Be aware that there is a critical period between the point where your code publishes its context for another thread to be able to call the Unblock method and the point where the actual method call to Block is made. During this period, you must not call any method which can in turn block and unblock for its own reasons (for example, acquiring a lock). Calls to the Block and Unblock method do not track the reason for the blocking and unblocking. Only one object should have ownership of a Block-Unblock pair.

This method can throw a variety of exceptions, including scheduler_resource_allocation_error.

Requirements

Header: concrt.h

Namespace: concurrency

See Also

Reference

Context Class

Context::Unblock Method

Concepts

Task Scheduler (Concurrency Runtime)