System.Net.WebClient.OpenReadAsync Method

Opens a readable stream containing the specified resource. This method does not block the calling thread.

Syntax

public void OpenReadAsync (Uri address)

Parameters

address
The URI of the resource to retrieve.

Remarks

This method retrieves a System.IO.Stream instance used to access the resource specified by the address parameter. The stream is obtained using thread resources that are automatically allocated from the thread pool. To receive notification when the stream is available, add an event handler to the WebClient.OpenReadCompleted event.

Note:

You must call System.IO.Stream.Close when you are finished with the System.IO.Stream to avoid running out of system resources.

This method does not block the calling thread while the stream is opening. To block while waiting for the stream, use the WebClient.OpenReadAsync(Uri) method.

Asynchronous operations that have not completed can be canceled using the WebClient.CancelAsync method.

If the WebClient.BaseAddress property is not an empty string ("") and address does not specify an absolute URI, address must be a relative URI that is combined with WebClient.BaseAddress to form the absolute URI of the requested resource. If the WebClient.QueryString property is not null, it is appended to address.

This method uses the RETR command to download an FTP resource. For an HTTP resource, the GET method is used.

Note:

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing.

Requirements

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