RpcCancelThread

The RpcCancelThread function cancels a thread.

This function is supported only by Windows NT.

#include <rpc.h>
RPC_STATUS RPC_ENTRY RpcCancelThread( 
  HANDLE  ThreadHandle  
);
 

Parameters

ThreadHandle
Specifies the handle of the thread to cancel.

Remarks

The RpcCancelThread routine allows one client thread to cancel an RPC in progress on another client thread. When the routine is called, the server runtime is informed of the cancel operation. The server stub can determine if the call has been cancelled by calling RpcTestCancel. If the call has been cancelled, the server stub should clean up and return control to the client.

By default, the client waits forever for the server to return control after a cancel. To reduce this time, call RpcMgmtSetCancelTimeout, specifying the number of seconds to wait for a response. If the server does not return within this interval, the call fails at the client with an RPC_S_CALL_FAILED exception. The server stub continues to execute.

If you are using the named pipes protocol, ncacn_np, you must specify a finite timeout.

Note  You can use RpcCancelThread with any of the connection-oriented protocols (ncacn_*) except ncacn_http, and with any of the datagram protocols except ncadg_mq and ncalrpc.

Return Values

Value Meaning
RPC_S_OK Success
RPC_S_ACCESS_DENIED Thread handle does not have privilege
RPC_S_CANNOT_SUPPORT Called by an MS-DOS or Windows 3.x client

QuickInfo

  Windows NT: Yes
  Windows CE: Unsupported.
  Header: Declared in rpcdce.h.
  Import Library: Link with rpcrt4.lib.