DownloadStringCompletedEventArgs Klasse

Definition

Stellt Daten für das DownloadStringCompleted-Ereignis bereit.

public ref class DownloadStringCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class DownloadStringCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type DownloadStringCompletedEventArgs = class
    inherit AsyncCompletedEventArgs
Public Class DownloadStringCompletedEventArgs
Inherits AsyncCompletedEventArgs
Vererbung
DownloadStringCompletedEventArgs

Beispiele

Das folgende Codebeispiel veranschaulicht das asynchrone Herunterladen einer Zeichenfolge.

// Sample call : DownloadStringInBackground2 ("http://www.contoso.com/GameScores.html");
public static void DownloadStringInBackground2(string address)
{
    WebClient client = new WebClient();
    Uri uri = new Uri(address);

    // Specify that the DownloadStringCallback2 method gets called
    // when the download completes.
    client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCallback2);
    client.DownloadStringAsync(uri);
}
'  Sample call : DownloadStringInBackground2 ("http:' www.contoso.com/GameScores.html")
Public Shared Sub DownloadStringInBackground2(ByVal address As String)

    Dim client As WebClient = New WebClient()

    '  Specify that the DownloadStringCallback2 method gets called
    '  when the download completes.
    AddHandler client.DownloadStringCompleted, AddressOf DownloadStringCallback2
                Dim uri as Uri = New Uri(address)
    client.DownloadStringAsync(uri)
End Sub

Die folgende Methode wird aufgerufen, wenn der Download abgeschlossen ist.

private static void DownloadStringCallback2(Object sender, DownloadStringCompletedEventArgs e)
{
    // If the request was not canceled and did not throw
    // an exception, display the resource.
    if (!e.Cancelled && e.Error == null)
    {
        string textString = (string)e.Result;

        Console.WriteLine(textString);
    }
}
Private Shared Sub DownloadStringCallback2(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)

    '  If the request was not canceled and did not throw
    '  an exception, display the resource.
    If e.Cancelled = False AndAlso e.Error Is Nothing Then

        Dim textString As String = CStr(e.Result)
        Console.WriteLine(textString)
    End If
End Sub

Hinweise

Instanzen dieser Klasse werden an die DownloadStringCompletedEventHandler.

Eigenschaften

Name Beschreibung
Cancelled

Ruft einen Wert ab, der angibt, ob ein asynchroner Vorgang abgebrochen wurde.

(Geerbt von AsyncCompletedEventArgs)
Error

Ruft einen Wert ab, der angibt, welcher Fehler während eines asynchronen Vorgangs aufgetreten ist.

(Geerbt von AsyncCompletedEventArgs)
Result

Ruft die Daten ab, die von einer DownloadStringAsync Methode heruntergeladen werden.

UserState

Ruft den eindeutigen Bezeichner für die asynchrone Aufgabe ab.

(Geerbt von AsyncCompletedEventArgs)

Methoden

Name Beschreibung
Equals(Object)

Bestimmt, ob das angegebene Objekt gleich dem aktuellen Objekt ist.

(Geerbt von Object)
GetHashCode()

Dient als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft die Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie der aktuellen Object.

(Geerbt von Object)
RaiseExceptionIfNecessary()

Löst eine vom Benutzer bereitgestellte Ausnahme aus, wenn ein asynchroner Vorgang fehlgeschlagen ist.

(Geerbt von AsyncCompletedEventArgs)
ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Gilt für: