Microsoft DirectX 8.1 (C++)

IDirectPlay8Peer::CancelAsyncOperation

Cancels asynchronous requests. For instance, several methods of the IDirectPlay8Peer 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 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.

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

Parameters

hAsyncHandle
[in] Handle of the asynchronous operation to stop. You receive this handle when you call one of several methods that support asynchronous operations. This value can be set to NULL to stop all operations or a particular type of asynchronous request. If you specify a particular handle for the request, the dwFlags parameter must be 0.
dwFlags
[in] Flag that specifies which asynchronous request is to be canceled. One of the following flags can be set.
DPNCANCEL_ENUM
Cancel all asynchronous IDirectPlay8Peer::EnumHosts requests. A single EnumHosts request can be canceled by specifying the handle returned from the EnumHosts method.
DPNCANCEL_CONNECT
Cancel an asynchronous IDirectPlay8Peer::Connect request.
DPNCANCEL_SEND
Cancel an asynchronous IDirectPlay8Peer::SendTo request.
DPNCANCEL_ALL_OPERATIONS
Cancel all asynchronous Connect, Send, and SentTo operations.

Return Values

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

DPNERR_CANNOTCANCEL
DPNERR_INVALIDFLAGS
DPNERR_INVALIDHANDLE

Remarks

You can use this method to cancel an asynchronous operation for the IDirectPlay8Peer::Connect, IDirectPlay8Peer::SendTo, and IDirectPlay8Peer::EnumHosts methods. Microsoft® DirectPlay® 8.1 does not support cancellation of other asynchronous operations.

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

If you set the DPNCANCEL_ALL_OPERATIONS, DPNCANCEL_CONNECT, DPNCANCEL_SEND, or DPNCANCEL_ENUM 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.

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.

Requirements

  Windows NT/2000/XP: Available as a redistributable for Windows 2000 and later.
  Windows 98/Me: Available as a redistributable for Windows 98 and later.
  Header: Declared in Dplay8.h.