Socket. Cancel IOAsync Method
public: virtual IAsyncAction ^ CancelIOAsync() = CancelIOAsync;
/// [Windows.Foundation.Metadata.RemoteAsync] IAsyncAction CancelIOAsync();
[Windows.Foundation.Metadata.RemoteAsync] public IAsyncAction CancelIOAsync();
Public Function CancelIOAsync () As IAsyncAction
An asynchronous cancel operation on a DatagramSocket object.
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.
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.