StreamSocket.CancelIOAsync StreamSocket.CancelIOAsync StreamSocket.CancelIOAsync StreamSocket.CancelIOAsync StreamSocket.CancelIOAsync Method

Definition

Cancels pending reads and writes over a StreamSocket object.

public : IAsyncAction CancelIOAsync()
IAsyncAction CancelIOAsync() const;
public IAsyncAction CancelIOAsync()
Public Function CancelIOAsync() As IAsyncAction
Windows.Networking.Sockets.StreamSocket.cancelioAsync().done( /* Your success and error handlers */ );

Returns

An asynchronous cancel operation on a StreamSocket object.

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.

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.