OpenReadCompletedEventArgs 클래스

정의

OpenReadCompleted 이벤트에 대한 데이터를 제공합니다.

public ref class OpenReadCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class OpenReadCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type OpenReadCompletedEventArgs = class
    inherit AsyncCompletedEventArgs
Public Class OpenReadCompletedEventArgs
Inherits AsyncCompletedEventArgs
상속
OpenReadCompletedEventArgs

예제

다음 코드 예제에서는 읽기에 대 한 리소스를 다운로드 하는 방법을 보여 줍니다.

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

다음 메서드는 다운로드가 완료 되 면 호출 됩니다.

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

설명

이 클래스의 인스턴스를 전달할 OpenReadCompletedEventHandler 메서드.

속성

Cancelled

비동기 작업이 취소되었는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 AsyncCompletedEventArgs)
Error

비동기 작업 중 발생한 오류를 나타내는 값을 가져옵니다.

(다음에서 상속됨 AsyncCompletedEventArgs)
Result

DownloadDataAsync 메서드로 다운로드한 데이터가 들어 있는 읽기 가능한 스트림을 가져옵니다.

UserState

비동기 작업의 고유 식별자를 가져옵니다.

(다음에서 상속됨 AsyncCompletedEventArgs)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
RaiseExceptionIfNecessary()

비동기 작업에 실패한 경우 사용자가 제공한 예외를 발생시킵니다.

(다음에서 상속됨 AsyncCompletedEventArgs)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상