C# Class GoogleApi.Extensions.WebClientExtension

Provides asynchronous extension methods based on the Task-based Asynchronous Pattern for the WebClient class.
The code below uses the guidelines outlined in the MSDN article "Simplify Asynchronous Programming with Tasks" at http://msdn.microsoft.com/en-us/magazine/ff959203.aspx under the "Converting an Event-Based Pattern" section, and follows the general TAP guidelines found at http://www.microsoft.com/en-us/download/details.aspx?id=19957.
Show file Open project: vivet/GoogleApi

Public Methods

Method Description
DownloadDataTaskAsync ( this webClient, Uri uri, CancellationToken token ) : Task

Asynchronously downloads the resource with the specified URI as a Byte array and allows cancelling the operation. Note that this overload specifies an infinite timeout.

DownloadDataTaskAsync ( this webClient, Uri uri, System.TimeSpan timeout ) : Task

Asynchronously downloads the resource with the specified URI as a Byte array limited by the specified timeout.

DownloadDataTaskAsync ( this webClient, Uri uri, System.TimeSpan timeout, CancellationToken token ) : Task

Asynchronously downloads the resource with the specified URI as a Byte array limited by the specified timeout and allows cancelling the operation.

Private Methods

Method Description
WebClientExtension ( ) : System

Static constructor.

Method Details

DownloadDataTaskAsync() public static method

Asynchronously downloads the resource with the specified URI as a Byte array and allows cancelling the operation. Note that this overload specifies an infinite timeout.
Thrown when a null value is passed to the client or address parameters.
public static DownloadDataTaskAsync ( this webClient, Uri uri, CancellationToken token ) : Task
webClient this The client with which to download the specified resource.
uri System.Uri The address of the resource to download.
token System.Threading.CancellationToken A cancellation token that can be used to cancel the pending asynchronous task.
return Task

DownloadDataTaskAsync() public static method

Asynchronously downloads the resource with the specified URI as a Byte array limited by the specified timeout.
Thrown when a null value is passed to the client or address parameters. Thrown when the value of timeout is neither a positive value or infinite.
public static DownloadDataTaskAsync ( this webClient, Uri uri, System.TimeSpan timeout ) : Task
webClient this The client with which to download the specified resource.
uri System.Uri The address of the resource to download.
timeout System.TimeSpan A TimeSpan specifying the amount of time to wait for a response before aborting the request. /// The specify an infinite timeout, pass a TimeSpan with a TotalMillisecond value of Timeout.Infinite. /// When a request is aborted due to a timeout the returned task will transition to the Faulted state with a TimeoutException.
return Task

DownloadDataTaskAsync() public static method

Asynchronously downloads the resource with the specified URI as a Byte array limited by the specified timeout and allows cancelling the operation.
Thrown when a null value is passed to the client or address parameters. Thrown when the value of timeout is neither a positive value or infinite.
public static DownloadDataTaskAsync ( this webClient, Uri uri, System.TimeSpan timeout, CancellationToken token ) : Task
webClient this The client with which to download the specified resource.
uri System.Uri The address of the resource to download.
timeout System.TimeSpan A TimeSpan specifying the amount of time to wait for a response before aborting the request. /// The specify an infinite timeout, pass a TimeSpan with a TotalMillisecond value of Timeout.Infinite. /// When a request is aborted due to a timeout the returned task will transition to the Faulted state with a TimeoutException.
token System.Threading.CancellationToken A cancellation token that can be used to cancel the pending asynchronous task.
return Task