Muokkaa

Jaa


ICLRTask2 Interface

Provides all the functionality of the ICLRTask interface; in addition, provides methods that allow thread aborts to be delayed on the current thread.

Methods

Method Description
BeginPreventAsyncAbort Method Delays new thread abort requests on the current thread.
EndPreventAsyncAbort Method Allows new or pending thread abort requests to result in thread aborts on the current thread.

Remarks

The ICLRTask2 interface inherits the ICLRTask interface and adds methods that allow the host to delay thread aborts, to protect a region of code that must not fail. Calling BeginPreventAsyncAbort increments the delay-thread-abort counter for the current thread, and calling EndPreventAsyncAbort decrements it. Calls to BeginPreventAsyncAbort and EndPreventAsyncAbort can be nested. As long as the counter is greater than zero, thread aborts for the current thread are delayed.

If calls to BeginPreventAsyncAbort and EndPreventAsyncAbort are not paired, it is possible to reach a state in which thread aborts cannot be delivered to the current thread.

The delay is not honored for a thread that aborts itself.

The functionality that is exposed by this feature is used internally by the virtual machine (VM). Misuse of these methods may cause unspecified behavior in the VM. For example, calling EndPreventAsyncAbort without first calling BeginPreventAsyncAbort could set the counter to zero when the VM has previously incremented it. Similarly, the internal counter is not checked for overflow. If it exceeds its integral limit because it is incremented by both the host and the VM, the resulting behavior is unspecified.

For information about members inherited from ICLRTask and about the other uses of this interface, see the ICLRTask interface.

Requirements

Platforms: See System Requirements.

Header: MSCorEE.h

Library: Included as a resource in MSCorEE.dll

.NET Framework Versions: Available since 4

See also