WebClient.UploadStringCompleted Událost

Definice

Nastane, když se dokončí asynchronní operace nahrání řetězce.

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

Event Type

Příklady

Následující příklad kódu ukazuje nastavení obslužné rutiny události pro tuto událost.

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

Následující příklad kódu ukazuje implementaci obslužné rutiny pro tuto událost.

void UploadStringCallback2( Object^ /*sender*/, UploadStringCompletedEventArgs^ e )
{
   String^ reply = dynamic_cast<String^>(e->Result);
   Console::WriteLine( reply );
}
private static void UploadStringCallback2(Object sender, UploadStringCompletedEventArgs e)
{
    string reply = (string)e.Result;
    Console.WriteLine(reply);
}
Private Shared Sub UploadStringCallback2(ByVal sender As Object, ByVal e As UploadStringCompletedEventArgs)
    Dim reply As String = CStr(e.Result)
    Console.WriteLine(reply)
End Sub

Poznámky

Opatrnost

WebRequest, HttpWebRequest, ServicePointa WebClient jsou zastaralé a neměli byste je používat pro nový vývoj. Místo toho použijte HttpClient.

Tato událost se vyvolá pokaždé, když se dokončí operace asynchronního nahrání řetězce. Asynchronní nahrání řetězců se spouští voláním metod UploadStringAsync.

UploadStringCompletedEventHandler je delegátem této události. Třída UploadStringCompletedEventArgs poskytuje obslužnou rutinu události s daty události.

Další informace o zpracování událostí naleznete v tématu zpracování a vyvolávání událostí.

Platí pro