CoEnableCallCancellation function (combaseapi.h)

Enables cancellation of synchronous calls on the calling thread.


HRESULT CoEnableCallCancellation(
  [in, optional] LPVOID pReserved


[in, optional] pReserved

This parameter is reserved and must be NULL.

Return value

This function can return the standard return values S_OK, E_FAIL, E_INVALIDARG, and E_OUTOFMEMORY.


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, synchronous calls cannot be canceled, even if a cancel object is available. To enable call cancellation, you must call CoEnableCallCancellation first.

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 CoDisableCallCancellation has been called once for each time CoEnableCallCancellation was called successfully.

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.


Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header combaseapi.h (include Objbase.h)
Library Ole32.lib
DLL Ole32.dll

See also