DownloadStringCompletedEventArgs 클래스

정의

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

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

예제

다음 코드 예제에서는 문자열을 비동기적으로 다운로드 하는 방법을 보여 줍니다.

// Sample call : DownloadStringInBackground2 ("http://www.contoso.com/GameScores.html");
void DownloadStringInBackground2( String^ address )
{
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);

   // Specify that the DownloadStringCallback2 method gets called
   // when the download completes.
   client->DownloadStringCompleted += gcnew DownloadStringCompletedEventHandler( DownloadStringCallback2 );
   client->DownloadStringAsync( uri );
}
// 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

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

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 == nullptr )
   {
      String^ textString = dynamic_cast<String^>(e->Result);
      Console::WriteLine( textString );
   }
}
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

설명

이 클래스의 인스턴스를 전달 되는 DownloadStringCompletedEventHandler합니다.

속성

Cancelled

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

(다음에서 상속됨 AsyncCompletedEventArgs)
Error

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

(다음에서 상속됨 AsyncCompletedEventArgs)
Result

DownloadStringAsync 메서드로 다운로드한 데이터를 가져옵니다.

UserState

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

(다음에서 상속됨 AsyncCompletedEventArgs)

메서드

Equals(Object)

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

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

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

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

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

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

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상