WebClient.UploadStringCompleted 事件


在异步字符串上载操作完成时发生。Occurs when an asynchronous string-upload operation completes.

 event System::Net::UploadStringCompletedEventHandler ^ UploadStringCompleted;
public event System.Net.UploadStringCompletedEventHandler UploadStringCompleted;
member this.UploadStringCompleted : System.Net.UploadStringCompletedEventHandler 
Public Event UploadStringCompleted As UploadStringCompletedEventHandler 


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

void UploadStringInBackground2( String^ address )
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);
   String^ data = "Time = 12:00am temperature = 50";

   client->UploadStringCompleted += gcnew UploadStringCompletedEventHandler( UploadStringCallback2 );
   client->UploadStringAsync( uri, data );

public static void UploadStringInBackground2 (string address)
    WebClient client = new WebClient ();
    Uri uri = new Uri(address);
    string data = "Time = 12:00am temperature = 50";
    client.UploadStringCompleted += new UploadStringCompletedEventHandler (UploadStringCallback2);
    client.UploadStringAsync (uri, data);

Public Shared Sub UploadStringInBackground2(ByVal address As String)

    Dim client As WebClient = New WebClient()
    Dim data As String = "Time = 12:00am temperature = 50"
    AddHandler client.UploadStringCompleted, AddressOf UploadStringCallback2
                Dim uri as Uri = New Uri(address)
    client.UploadStringAsync(uri, data)
End Sub


此事件在每次异步字符串上传操作完成时引发。This event is raised each time an asynchronous string upload operation completes. 异步字符串上传通过调用 UploadStringAsync 方法来启动。Asynchronous string uploads are started by calling the UploadStringAsync methods.

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

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