WebClient.OpenReadCompleted 事件


在以下异步操作完成时发生,该操作打开包含某个资源的流。Occurs when an asynchronous operation to open a stream containing a resource completes.

 event System::Net::OpenReadCompletedEventHandler ^ OpenReadCompleted;
public event System.Net.OpenReadCompletedEventHandler OpenReadCompleted;
member this.OpenReadCompleted : System.Net.OpenReadCompletedEventHandler 
Public Event OpenReadCompleted As OpenReadCompletedEventHandler 


下面的代码示例演示如何为此事件设置事件处理程序。The following code example demonstrates setting an event handler for this event.

void OpenResourceForReading2( String^ address )
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);

   client->OpenReadCompleted += gcnew OpenReadCompletedEventHandler( OpenReadCallback2 );
   client->OpenReadAsync( uri );

public static void OpenResourceForReading2 (string address)
    WebClient client = new WebClient ();
    Uri uri = new Uri(address);

    client.OpenReadCompleted += new OpenReadCompletedEventHandler(OpenReadCallback2);
    client.OpenReadAsync (uri);

Public Shared Sub OpenResourceForReading2(ByVal address As String)

    Dim client As WebClient = New WebClient()
    AddHandler client.OpenReadCompleted, AddressOf OpenReadCallback2
                Dim uri as Uri = New Uri(address)
End Sub


此事件在每次打开包含资源的流的异步操作完成时引发。This event is raised each time an asynchronous operation to open a stream containing a resource completes. 这些操作通过调用 OpenReadAsync 方法来启动。These operations are started by calling the OpenReadAsync methods.

OpenReadCompletedEventHandler 是此事件的委托。The OpenReadCompletedEventHandler is the delegate for this event. OpenReadCompletedEventArgs 类向事件处理程序提供事件数据。The OpenReadCompletedEventArgs class provides the event handler with event data.

有关如何处理事件的详细信息,请参阅处理和引发事件For more information about how to handle events, see Handling and Raising Events.