IDirectPlay8Server::CancelAsyncOperation Method

DirectPlay

 
Microsoft DirectX 9.0 SDK Update (Summer 2003)

IDirectPlay8Server::CancelAsyncOperation Method


Cancels asynchronous requests. Many methods of the IDirectPlay8Server interface run asynchronously by default. Depending on the situation, you might want to cancel requests before they are processed. All the methods of this interface that can be run asynchronously return an hAsyncHandle parameter.

Specific requests are canceled by passing the hAsyncHandle of the request in this method's hAsyncHandle parameter. You can cancel all pending asynchronous operations by calling this method, specifying NULL in the hAsyncHandle parameter, and specifying DPNCANCEL_ALL_OPERATIONS in the dwFlags parameter. If a specific handle is provided to this method, no flags should be set.

Syntax

HRESULT CancelAsyncOperation(      
    const DPNHANDLE hAsyncHandle,     const DWORD dwFlags );

Parameters

hAsyncHandle
[in] Handle of the asynchronous operation to stop. This value can be NULL to stop all requests or a particular type of asynchronous request. If a specific handle is specified, the dwFlags parameter must be 0. You will receive this handle when you call one of several methods that support asynchronous operations. If one of the DPNCANCEL_PLAYER_SENDS flags is specified in the dwFlags parameter, hAsyncHandle must be set to a player's DPNID.
dwFlags
[in] Flag that specifies which asynchronous request to cancel. You can set one of the following flags.
DPNCANCEL_SEND
Cancel an asynchronous IDirectPlay8Server::SendTo request.
DPNCANCEL_PLAYER_SENDS
Cancel all asynchronous IDirectPlay8Server::SendTo requests for the player specified in the hAsyncHandle parameter.
DPNCANCEL_PLAYER_SENDS_PRIORITY_LOW
Cancel low-priority asynchronous IDirectPlay8Server::SendTo requests for the player specified in the hAsyncHandle parameter.
DPNCANCEL_PLAYER_SENDS_PRIORITY_NORMAL
Cancel normal-priority asynchronous IDirectPlay8Server::SendTo requests for the player specified in the hAsyncHandle parameter.
DPNCANCEL_PLAYER_SENDS_PRIORITY_HIGH
Cancel high-priority asynchronous IDirectPlay8Server::SendTo requests for the player specified in the hAsyncHandle parameter.
DPNCANCEL_ALL_OPERATIONS
Cancel all asynchronous requests.

Return Value

Returns S_OK if successful, or one of the following error values.

DPNERR_CANNOTCANCELThe operation could not be canceled.
DPNERR_INVALIDFLAGSThe flags passed to this method are invalid.
DPNERR_INVALIDHANDLEThe handle specified is invalid.
DPNSUCCESS_PENDINGAn asynchronous operation has reached the point where it is successfully queued.

Remarks

You can use this method to cancel an asynchronous operation for the IDirectPlay8Server::SendTo method. Microsoft® DirectPlay® does not support cancellation of other asynchronous operations.

You can cancel a IDirectPlay8Server::SendTo request by providing the handle returned from IDirectPlay8Server::SendTo method. A DPN_MSGID_SEND_COMPLETE system message is still posted to the applications message handler for each asynchronous IDirectPlay8Server::SendTo request that is sent without the DPNSEND_NOCOMPLETE flag set. Send requests that are canceled by this method return DPNERR_USERCANCEL in their hResultCode member of the DPN_MSGID_SEND_COMPLETE message.

If you set the DPNCANCEL_ALL_OPERATIONS or DPNCANCEL_SEND flags in dwFlags, DirectPlay will attempt to cancel all matching operations. This method will return an error if any attempted cancellation fails, even though some cancellations may have been successful.

If you set one of the DPNCANCEL_PLAYER_SENDS flags in dwFlags, you must specify a player's DPNID in hAsyncHandle. This will cancel all pending IDirectPlay8Server::SendTo requests where the DPNID specified in the dpnid parameter matches the value set in the hAsyncHandle parameter.

Note  The completion message might not arrive until after this method returns. Do not assume that the operation has been terminated until you have received a DPN_MSGID_SEND_COMPLETE, DPN_MSGID_CONNECT_COMPLETE, or DPN_MSGID_ASYNC_OP_COMPLETE message.



© 2003 Microsoft Corporation. All rights reserved.