[Applies to UMDF 1.x only]
The OnCancel method is called when an application cancels an I/O operation through the Microsoft Win32 CancelIo, CancelIoEx, or CancelSynchronousIo function.
- pWdfRequest [in]
A pointer to the IWDFIoRequest interface that represents the framework request object to cancel.
The framework calls the OnCancel method to cancel the I/O request that the pWdfRequest parameter identifies. The driver should first determine whether it can cancel the I/O request. If the request can be canceled, the driver should cancel it. For more information about how to cancel a request, see Canceling I/O Requests.
If the driver cancels the request, the driver must also complete the request by calling the IWDFIoRequest::Complete method with the CompletionStatus parameter set to HRESULT_FROM_WIN32(ERROR_OPERATION_ABORTED).
The framework does not call OnCancel to cancel a request unless the driver previously called the IWDFIoRequest::MarkCancelable method to enable cancellation of the request and to register the IRequestCallbackCancel interface.
The User-Mode Driver Framework (UMDF) allows only one OnCancel method per queue. Therefore, when a driver calls IWDFIoRequest::MarkCancelable for requests that are associated with a particular queue to enable the framework to cancel those requests, the driver must pass a pointer to the IRequestCallbackCancel interface for the same request-callback object. Later, to cancel each request, the framework passes a pointer to the IWDFIoRequest interface for the request in a call to this request-callback object's OnCancel method.