WebClient.UploadDataCompleted 事件

定义

在异步数据上载操作完成时发生。Occurs when an asynchronous data-upload operation completes.

public:
 event System::Net::UploadDataCompletedEventHandler ^ UploadDataCompleted;
public event System.Net.UploadDataCompletedEventHandler UploadDataCompleted;
member this.UploadDataCompleted : System.Net.UploadDataCompletedEventHandler 
Public Event UploadDataCompleted As UploadDataCompletedEventHandler 

示例

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

void UploadDataInBackground3( String^ address )
{
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);
   String^ text = "Time = 12:00am temperature = 50";
   array<Byte>^data = System::Text::Encoding::UTF8->GetBytes( text );

   client->UploadDataCompleted += gcnew UploadDataCompletedEventHandler( UploadDataCallback3 );
   client->UploadDataAsync( uri, data );
}


public static void UploadDataInBackground3 (string address)
{
    WebClient client = new WebClient ();
    Uri uri = new Uri(address);
    string text = "Time = 12:00am temperature = 50";
    byte[] data = System.Text.Encoding.UTF8.GetBytes (text);

    client.UploadDataCompleted += new UploadDataCompletedEventHandler (UploadDataCallback3);
    client.UploadDataAsync (uri, data);
}

Public Shared Sub UploadDataInBackground3(ByVal address As String)

    Dim client As WebClient = New WebClient()
    Dim text As String = "Time = 12:00am temperature = 50"
    Dim data() As Byte = System.Text.Encoding.UTF8.GetBytes(text)
    AddHandler client.UploadDataCompleted, AddressOf UploadDataCallback3
                Dim uri as Uri = New Uri(address)
    client.UploadDataAsync(uri, data)
End Sub

注解

每次异步数据上传操作完成时都会引发此事件。This event is raised each time an asynchronous data upload operation completes. 异步数据上传通过调用 UploadDataAsync 方法来启动。Asynchronous data uploads are started by calling the UploadDataAsync methods.

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

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

适用于