DownloadDataCompletedEventArgsとは? わかりやすく解説

DownloadDataCompletedEventArgs クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

DownloadDataCompleted イベントデータ提供します

名前空間: System.Net
アセンブリ: System (system.dll 内)
構文構文

Public Class DownloadDataCompletedEventArgs
    Inherits AsyncCompletedEventArgs
Dim instance As DownloadDataCompletedEventArgs
public class DownloadDataCompletedEventArgs
 : AsyncCompletedEventArgs
public ref class DownloadDataCompletedEventArgs
 : public AsyncCompletedEventArgs
public class DownloadDataCompletedEventArgs
 extends AsyncCompletedEventArgs
public class DownloadDataCompletedEventArgs
 extends AsyncCompletedEventArgs
解説解説

このクラスインスタンスは 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 ();
    }
}

継承階層継承階層
System.Object
   System.EventArgs
     System.ComponentModel.AsyncCompletedEventArgs
      System.Net.DownloadDataCompletedEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DownloadDataCompletedEventArgs メンバ
System.Net 名前空間

DownloadDataCompletedEventArgs プロパティ


パブリック プロパティパブリック プロパティ

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

関連項目

DownloadDataCompletedEventArgs クラス
System.Net 名前空間

DownloadDataCompletedEventArgs メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DownloadDataCompletedEventArgs クラス
System.Net 名前空間

DownloadDataCompletedEventArgs メンバ

DownloadDataCompleted イベントデータ提供します

DownloadDataCompletedEventArgs データ型公開されるメンバを以下の表に示します


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

関連項目

DownloadDataCompletedEventArgs クラス
System.Net 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からDownloadDataCompletedEventArgsを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDownloadDataCompletedEventArgsを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDownloadDataCompletedEventArgs を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DownloadDataCompletedEventArgs」の関連用語

DownloadDataCompletedEventArgsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DownloadDataCompletedEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS