DownloadDataCompletedEventArgs クラス
アセンブリ: System (system.dll 内)



ユーザー指定のリソースをダウンロードするコード例を次に示します。
' 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 (); } }

System.EventArgs
System.ComponentModel.AsyncCompletedEventArgs
System.Net.DownloadDataCompletedEventArgs


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DownloadDataCompletedEventArgs プロパティ

名前 | 説明 | |
---|---|---|
![]() | Cancelled | 非同期操作がキャンセルされたかどうかを示す値を取得します。 ( AsyncCompletedEventArgs から継承されます。) |
![]() | Error | 非同期操作中に発生したエラーを示す値を取得します。 ( AsyncCompletedEventArgs から継承されます。) |
![]() | Result | DownloadDataAsync メソッドによってダウンロードされたデータを取得します。 |
![]() | UserState | 非同期タスクの一意の識別子を取得します。 ( AsyncCompletedEventArgs から継承されます。) |

DownloadDataCompletedEventArgs メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
![]() | RaiseExceptionIfNecessary | 非同期操作が失敗した場合は、ユーザー指定の例外を発生させます。 ( AsyncCompletedEventArgs から継承されます。) |

DownloadDataCompletedEventArgs メンバ
DownloadDataCompleted イベントのデータを提供します。
DownloadDataCompletedEventArgs データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | Cancelled | 非同期操作がキャンセルされたかどうかを示す値を取得します。(AsyncCompletedEventArgs から継承されます。) |
![]() | Error | 非同期操作中に発生したエラーを示す値を取得します。(AsyncCompletedEventArgs から継承されます。) |
![]() | Result | DownloadDataAsync メソッドによってダウンロードされたデータを取得します。 |
![]() | UserState | 非同期タスクの一意の識別子を取得します。(AsyncCompletedEventArgs から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
![]() | RaiseExceptionIfNecessary | 非同期操作が失敗した場合は、ユーザー指定の例外を発生させます。 (AsyncCompletedEventArgs から継承されます。) |

- DownloadDataCompletedEventArgsのページへのリンク