CoTestCancel

[This is preliminary documentation and subject to change.]

Determines if the call being executed on the server has been canceled by the client.

HRESULT CoTestCancel(void);
 

Return values

This function supports the standard return values E_FAIL, E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:

RPC_S_CALLPENDING
The call is still pending and has not yet been canceled by the client
RPC_E_CALL_CANCELED
The call has been canceled by the client

Remarks

Server objects should call CoTestCancel at least once before returning to detect client cancellation requests. Doing so can save the server unnecessary work if the client has issued a cancellation request, and it can reduce the client's wait time if it has set the cancel timeout as RPC_C_CANCEL_INFINITE_TIMEOUT. Furthermore, if the server object detects a cancellation request before returning from a pending call, it can clean up any memory, marshaled interfaces, or handles it has created or obtained.

CoTestCancel calls CoGetCallContext to obtain the ICancelMethodCalls interface on the current cancel object and then calls ICancelMethodCalls::TestCancel. Objects that implement custom marshaling should first call CoSwitchCallContext to install the appropriate call context object.

This function does not test cancel for asynchronous calls.

QuickInfo

  Windows NT: Use version 5.0 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in objbase.h.
  Import Library: Included as a resource in ole32.dll.