OpenReadCompletedEventArgs

System.Net

Summary

Encapsulates the data for an event that is raised when an asynchronous read operation completes.

Syntax

public class OpenReadCompletedEventArgs : EventArgs

Remarks

The OpenReadCompletedEventArgs class holds the result of an asynchronous operation to open a stream for reading a resource. This class is used with the OpenReadCompleted event of the WebClient class.

When an OpenReadAsync method call completes, the OpenReadCompleted event is raised. The event handler for this event receives an instance of OpenReadCompletedEventArgs.

You can use the properties of the OpenReadCompletedEventArgs object to determine if the operation was successful, to get the resulting stream, or to retrieve any error that occurred.

Constructors

OpenReadCompletedEventArgs

public OpenReadCompletedEventArgs (Stream? result, Exception? error, bool cancelled, object? userState);

Parameters

  • result: The stream that contains the downloaded data. This parameter is null if an error occurred or the operation was canceled.
  • error: An exception that occurred during the operation. This parameter is null if no error occurred.
  • cancelled: true if the operation was canceled; otherwise, false.
  • userState: A user-supplied object that distinguishes this particular asynchronous operation from other operations.

Properties

Result

public Stream? Result { get; }
Gets the stream that contains the downloaded data.
If the asynchronous operation was canceled or an error occurred, this property will return null.

Error

public Exception? Error { get; }
Gets an exception that occurred during the operation.
If the asynchronous operation completed successfully, this property will be null.

Cancelled

public bool Cancelled { get; }
Gets a value indicating whether the asynchronous operation was canceled.

UserState

public object? UserState { get; }
Gets the user-supplied object that distinguishes this particular asynchronous operation from other operations.