Call cancellation
Call cancellation notification cancels the operation of server side service operations and service-model callbacks. Such cancellation can be for one of two reasons:
- The service host has stopped operations because of a call to the WsAbortServiceHost function.
- The underlying channel has raised a fault.
To receive a cancellation notification, the service operation or service-model callback must register a WS_OPERATION_CANCEL_CALLBACK callback by calling the WsRegisterOperationForCancel function.
Optionally, as part of the registering for cancellation notification, the service operation or service-model callback can also register application-specific state data and the WS_OPERATION_FREE_STATE_CALLBACK callback.
The state data is made available to the WS_OPERATION_CANCEL_CALLBACK callback. On call completion, the WS_OPERATION_FREE_STATE_CALLBACK callback is called to give the application an opportunity to free the state data.
For a code example, see BlockingServiceExample.
The cancellation callback is called only once for the lifetime of the server side service operations or callback function.
Call cancellation is available in for all service host callbacks that take WS_OPERATION_CONTEXT as a parameter.
The following API elements relate to call cancellation.
Callback | Description |
---|---|
WS_OPERATION_CANCEL_CALLBACK | Invoked by service model to notify a cancellation of an asynchronous service operation as a result of an aborted shutdown of service host. |
WS_OPERATION_FREE_STATE_CALLBACK | Invoked by service model to allow an application to clean up state data that was registered with the cancellation callback. |
Function | Description |
---|---|
WsRegisterOperationForCancel | Allows a service operation or service-model callback to register for a cancellation notification. |