Share via


DatagramSocket.CancelIOAsync Method

Definition

Cancels pending reads and writes over a DatagramSocket object.

public:
 virtual IAsyncAction ^ CancelIOAsync() = CancelIOAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction CancelIOAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction CancelIOAsync();
function cancelIOAsync()
Public Function CancelIOAsync () As IAsyncAction

Returns

An asynchronous cancel operation on a DatagramSocket object.

Attributes

Remarks

Call CancelIOAsync to cancel any pending reads or writes on this socket before you call TransferOwnership when your app is about to be suspended.

CancelIOAsync does not guarantee that all read/write completion handlers have finished executing before it signals completion. It does, however, guarantee that all I/O operations will have reached a terminal state (either Completed or Error) by the time it signals completion. If your app needs to wait for all pending I/O operation handlers to finish executing, you must implement your own app-level sychronization logic. The Socket Activity Stream Socket sample demonstrates one way to do this for StreamSocket. The technique is similar for DatagramSocket.

Note

CancelIOAsync cancels pending writes and reads in the Windows Runtime, but if there is a write buffer pending in networking drivers, it flushes the write.

Applies to