OpenReadCompletedEventArgs OpenReadCompletedEventArgs OpenReadCompletedEventArgs OpenReadCompletedEventArgs Class

Definition

Stellt Daten für das OpenReadCompleted-Ereignis bereit.Provides data for the OpenReadCompleted event.

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

Beispiele

Im folgenden Codebeispiel veranschaulicht das Herunterladen einer Ressource zum Lesen.The following code example demonstrates downloading a resource for reading.

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)
	client.OpenReadAsync(uri)                        
End Sub

Die folgende Methode wird aufgerufen, wenn der Download abgeschlossen ist.The following method is called when the download completes.

void OpenReadCallback2( Object^ /*sender*/, OpenReadCompletedEventArgs^ e )
{
   Stream^ reply = nullptr;
   StreamReader^ s = nullptr;
   try
   {
      reply = dynamic_cast<Stream^>(e->Result);
      s = gcnew StreamReader( reply );
      Console::WriteLine( s->ReadToEnd() );
   }
   finally
   {
      if ( s != nullptr )
      {
         s->Close();
      }
      if ( reply != nullptr )
      {
         reply->Close();
      }
   }

}


private static void OpenReadCallback2 (Object sender, OpenReadCompletedEventArgs e)
{
    Stream reply = null;
    StreamReader s = null;

    try
    {
        reply = (Stream)e.Result;
        s = new StreamReader (reply);
        Console.WriteLine (s.ReadToEnd ());
    }
    finally
    {
        if (s != null)
        {
            s.Close ();
        }

        if (reply != null)
        {
            reply.Close ();
        }
    }
}

Private Shared Sub OpenReadCallback2(ByVal sender As Object, ByVal e As OpenReadCompletedEventArgs)

    Dim reply As Stream = Nothing
    Dim s As StreamReader = Nothing

    Try

        reply = CType(e.Result, Stream)
        s = New StreamReader(reply)
        Console.WriteLine(s.ReadToEnd())
    Finally

        If Not s Is Nothing Then

            s.Close()
        End If

        If Not reply Is Nothing Then

            reply.Close()
        End If
    End Try
End Sub

Hinweise

Instanzen dieser Klasse werden an übergeben OpenReadCompletedEventHandler Methoden.Instances of this class are passed to OpenReadCompletedEventHandler methods.

Eigenschaften

Cancelled Cancelled Cancelled Cancelled

Ruft einen Wert ab, der angibt, ob ein asynchroner Vorgang abgebrochen wurde.Gets a value indicating whether an asynchronous operation has been canceled.

(Inherited from AsyncCompletedEventArgs)
Error Error Error Error

Ruft einen Wert ab, der angibt, welcher Fehler während eines asynchronen Vorgangs aufgetreten ist.Gets a value indicating which error occurred during an asynchronous operation.

(Inherited from AsyncCompletedEventArgs)
Result Result Result Result

Ruft einen lesbaren Stream ab, der von einer DownloadDataAsync-Methode heruntergeladene Daten enthält.Gets a readable stream that contains data downloaded by a DownloadDataAsync method.

UserState UserState UserState UserState

Ruft den eindeutigen Bezeichner der asynchronen Aufgabe ab.Gets the unique identifier for the asynchronous task.

(Inherited from AsyncCompletedEventArgs)

Methoden

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Bestimmt, ob das angegebene Objekt mit dem aktuellen Objekt identisch ist.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Fungiert als Standardhashfunktion.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Ruft den Type der aktuellen Instanz ab.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.Creates a shallow copy of the current Object.

(Inherited from Object)
RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary()

Löst eine benutzerdefinierte Ausnahme aus, wenn bei einem asynchronen Vorgang ein Fehler aufgetreten ist.Raises a user-supplied exception if an asynchronous operation failed.

(Inherited from AsyncCompletedEventArgs)
ToString() ToString() ToString() ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.Returns a string that represents the current object.

(Inherited from Object)

Gilt für: