CoDisableCallCancellation function

Undoes the action of a call to CoEnableCallCancellation. Disables cancellation of synchronous calls on the calling thread when all calls to CoEnableCallCancellation are balanced by calls to CoDisableCallCancellation.


HRESULT CoDisableCallCancellation(
  _In_opt_ LPVOID pReserved


pReserved [in, optional]

This parameter is reserved and must be NULL.

Return value

This function can return the standard return values E_FAIL, E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values.

Return codeDescription

Call cancellation was successfully disabled on the thread.


There have been more successful calls to CoEnableCallCancellation on the thread than there have been calls to CoDisableCallCancellation. Cancellation is still enabled on the thread.



When call cancellation is enabled on a thread, marshaled synchronous calls from that thread to objects on the same computer can suffer serious performance degradation. By default, then, synchronous calls cannot be canceled, even if a cancel object is available. To enable call cancellation, you must call CoEnableCallCancellation first.

When call cancellation is disabled, attempts to gain a pointer to a call object will fail. If the calling thread already has a pointer to a call object, calls on that object will fail.

Unless you want to enable call cancellation on a thread at all times, you should pair calls to CoEnableCallCancellation with calls to CoDisableCallCancellation. Call cancellation is disabled only if each successful call to CoEnableCallCancellation is balanced by a successful call to CoDisableCallCancellation.

A call will be cancelable or not depending on the state of the thread at the time the call was made. Subsequently enabling or disabling call cancellation has no effect on any calls that are pending on the thread.

If a thread is uninitialized and then reinitialized by calls to CoUninitialize and CoInitialize, call cancellation is disabled on the thread, even if it was enabled when the thread was uninitialized.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]







See also