DownloadDataCompletedEventHandler デリゲート
アセンブリ: System (system.dll 内)

Public Delegate Sub DownloadDataCompletedEventHandler ( _ sender As Object, _ e As DownloadDataCompletedEventArgs _ )
public delegate void DownloadDataCompletedEventHandler ( Object sender, DownloadDataCompletedEventArgs e )
public delegate void DownloadDataCompletedEventHandler ( Object^ sender, DownloadDataCompletedEventArgs^ e )
/** @delegate */ public delegate void DownloadDataCompletedEventHandler ( Object sender, DownloadDataCompletedEventArgs e )

DownloadDataCompletedEventHandler デリゲートを作成する場合は、イベントを処理するメソッドを識別してください。イベントをイベント ハンドラに関連付けるには、デリゲートのインスタンスをイベントに追加します。デリゲートを削除しない限り、そのイベントが発生すると常にイベント ハンドラが呼び出されます。イベント ハンドラ デリゲートの詳細については、「イベントとデリゲート」を参照してください。

ユーザー指定のリソースをダウンロードする方法を次のコード例に示します。
' 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
// 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 (); }
Public Shared Sub DownloadDataCallback(ByVal sender As Object, ByVal e As DownloadDataCompletedEventArgs) Dim waiter As System.Threading.AutoResetEvent = CType(e.UserState, System.Threading.AutoResetEvent) Try ' 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 data() As Byte = CType(e.Result, Byte()) Dim textData As String = System.Text.Encoding.UTF8.GetString(data) Console.WriteLine(textData) End If Finally ' Let the main application thread resume. waiter.Set() End Try End Sub
public static void DownloadDataCallback (Object sender, DownloadDataCompletedEventArgs e) { System.Threading.AutoResetEvent waiter = (System.Threading.AutoResetEvent)e.UserState; try { // If the request was not canceled and did not throw // an exception, display the resource. if (!e.Cancelled && e.Error == null) { byte[] data = (byte[])e.Result; string textData = System.Text.Encoding.UTF8.GetString (data); Console.WriteLine (textData); } } finally { // Let the main application thread resume. waiter.Set (); } }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDownloadDataCompletedEventHandler デリゲートを検索する場合は、下記のリンクをクリックしてください。

- DownloadDataCompletedEventHandler デリゲートのページへのリンク