System.Net.WebClient.CancelAsync Method

Cancels a pending asynchronous operation.

Syntax

public void CancelAsync ()

Remarks

If an operation is pending, this method calls WebRequest.Abort on the underlying System.Net.WebRequest.

When you call WebClient.CancelAsync, your application still receives the completion event associated with the operation. For example, when you call WebClient.CancelAsync to cancel a erload:System.Net.WebClient.DownloadStringAsync operation, if you have specified an event handler for the WebClient.DownloadStringCompleted event, your event handler receives notification that the operation has ended. To learn whether the operation completed successfully, check the System.ComponentModel.AsyncCompletedEventArgs.Cancelled property on the base class of System.Net.DownloadDataCompletedEventArgs in the event data object passed to the event handler.

If no asynchronous operation is in progress, this method does nothing.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0