WebClient.DownloadStringCompleted イベント

定義

非同期のリソース ダウンロード操作の完了時に発生します。Occurs when an asynchronous resource-download operation completes.

public:
 event System::Net::DownloadStringCompletedEventHandler ^ DownloadStringCompleted;
public event System.Net.DownloadStringCompletedEventHandler? DownloadStringCompleted;
public event System.Net.DownloadStringCompletedEventHandler DownloadStringCompleted;
member this.DownloadStringCompleted : System.Net.DownloadStringCompletedEventHandler 
Public Custom Event DownloadStringCompleted As DownloadStringCompletedEventHandler 
Public Event DownloadStringCompleted As DownloadStringCompletedEventHandler 

イベントの種類

DownloadStringCompletedEventHandler

次のコード例は、このイベントのイベントハンドラーを設定する方法を示しています。The following code example demonstrates setting an event handler for this event.

// 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

注釈

このイベントは、リソースを文字列としてダウンロードする非同期操作が完了するたびに発生します。This event is raised each time an asynchronous operation to download a resource as a string completes. これらの操作は、メソッドを呼び出すことによって開始され DownloadStringAsync ます。These operations are started by calling the DownloadStringAsync methods.

は、 DownloadStringCompletedEventHandler このイベントのデリゲートです。The DownloadStringCompletedEventHandler is the delegate for this event. クラスは、イベント DownloadStringCompletedEventArgs データを含むイベントハンドラーを提供します。The DownloadStringCompletedEventArgs class provides the event handler with event data.

イベントを処理する方法の詳細については、次を参照してください。処理とイベントの発生します。For more information about how to handle events, see Handling and Raising Events.

適用対象