WebClient.DownloadDataCompleted 이벤트

정의

비동기 데이터 다운로드 작업이 완료되면 발생합니다.

public:
 event System::Net::DownloadDataCompletedEventHandler ^ DownloadDataCompleted;
public event System.Net.DownloadDataCompletedEventHandler? DownloadDataCompleted;
public event System.Net.DownloadDataCompletedEventHandler DownloadDataCompleted;
member this.DownloadDataCompleted : System.Net.DownloadDataCompletedEventHandler 
Public Custom Event DownloadDataCompleted As DownloadDataCompletedEventHandler 
Public Event DownloadDataCompleted As DownloadDataCompletedEventHandler 

이벤트 유형

DownloadDataCompletedEventHandler

예제

다음 코드 예제에서는이 이벤트에 대 한 이벤트 처리기를 설정 하는 방법을 보여 줍니다.

// Sample call : DownLoadDataInBackground ("http://www.contoso.com/GameScores.html");
void DownloadDataInBackground( String^ address )
{
   System::Threading::AutoResetEvent^ waiter = gcnew System::Threading::AutoResetEvent( false );
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);

   // Specify that the DownloadDataCallback method gets called
   // when the download completes.
   client->DownloadDataCompleted += gcnew DownloadDataCompletedEventHandler( DownloadDataCallback );
   client->DownloadDataAsync( uri, waiter );

   // Block the main application thread. Real applications
   // can perform other tasks while waiting for the download to complete.
   waiter->WaitOne();
}
// Sample call : DownLoadDataInBackground ("http://www.contoso.com/GameScores.html");
public static void DownloadDataInBackground(string address)
{
    System.Threading.AutoResetEvent waiter = new System.Threading.AutoResetEvent(false);
    WebClient client = new WebClient();
    Uri uri = new Uri(address);

    // Specify that the DownloadDataCallback method gets called
    // when the download completes.
    client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(DownloadDataCallback);
    client.DownloadDataAsync(uri, waiter);

    // Block the main application thread. Real applications
    // can perform other tasks while waiting for the download to complete.
    waiter.WaitOne();
}
'  Sample call : DownLoadDataInBackground ("http:' www.contoso.com/GameScores.html")
Public Shared Sub DownloadDataInBackground(ByVal address As String)

    Dim waiter As System.Threading.AutoResetEvent = New System.Threading.AutoResetEvent(False)
    Dim client As WebClient = New WebClient()

    '  Specify that the DownloadDataCallback method gets called
    '  when the download completes.
    AddHandler client.DownloadDataCompleted, AddressOf DownloadDataCallback
                Dim uri as Uri = New Uri(address)
    client.DownloadDataAsync(uri, waiter)

    '  Block the main application thread. Real applications
    '  can perform other tasks while waiting for the download to complete.
    waiter.WaitOne()
End Sub

설명

이 이벤트는 비동기 데이터 다운로드 작업이 완료될 때마다 발생합니다. 비동기 데이터 다운로드는 메서드를 호출 DownloadDataAsync 하여 시작됩니다.

DownloadDataCompletedEventHandler 이벤트의 대리자입니다. 이 클래스는 DownloadDataCompletedEventArgs 이벤트 처리기에 이벤트 데이터를 제공합니다.

이벤트를 처리 하는 방법에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

적용 대상