WebClient.DownloadProgressChanged イベント
アセンブリ: System (system.dll 内)

Dim instance As WebClient Dim handler As DownloadProgressChangedEventHandler AddHandler instance.DownloadProgressChanged, handler
public: event DownloadProgressChangedEventHandler^ DownloadProgressChanged { void add (DownloadProgressChangedEventHandler^ value); void remove (DownloadProgressChangedEventHandler^ value); }

このイベントは、非同期ダウンロードが進行するたびに発生します。このイベントは、次のメソッドのいずれかを使用してダウンロードが開始されたときに発生します。
DownloadDataAsync | |
DownloadFileAsync | |
OpenReadAsync |
DownloadProgressChangedEventHandler は、このイベントのデリゲートです。DownloadProgressChangedEventArgs クラスは、イベント ハンドラにイベント データを提供します。

このイベントのイベント ハンドラを設定するコード例を次に示します。
' Sample call : DownLoadFileInBackground2 ("http:' www.contoso.com/logs/January.txt") Public Shared Sub DownLoadFileInBackground2(ByVal address As String) Dim client As WebClient = New WebClient() ' Specify that the DownloadFileCallback method gets called ' when the download completes. AddHandler client.DownloadFileCompleted, AddressOf DownloadFileCallback2 ' Specify a progress notification handler. AddHandler client.DownloadProgressChanged, AddressOf DownloadProgressCallback Dim uri as Uri = New Uri(address) client.DownloadFileAsync(uri, "serverdata.txt") End Sub
// Sample call : DownLoadFileInBackground2 ("http://www.contoso.com/logs/January.txt"); public static void DownLoadFileInBackground2 (string address) { WebClient client = new WebClient (); Uri uri = new Uri(address); // Specify that the DownloadFileCallback method gets called // when the download completes. client.DownloadFileCompleted += new AsyncCompletedEventHandler (DownloadFileCallback2); // Specify a progress notification handler. client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback); client.DownloadFileAsync (uri, "serverdata.txt"); }
Shared Sub UploadProgressCallback(ByVal sender As Object, ByVal e As UploadProgressChangedEventArgs) ' Displays the operation identifier, and the transfer progress. Console.WriteLine("{0} uploaded {1} of {2} bytes. {3} % complete...", _ CStr(e.UserState), e.BytesSent, e.TotalBytesToSend, e.ProgressPercentage) End Sub Shared Sub DownloadProgressCallback(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) ' Displays the operation identifier, and the transfer progress. Console.WriteLine("0} downloaded 1} of 2} bytes. 3} % complete...", _ CStr(e.UserState), e.BytesReceived, e.TotalBytesToReceive, e.ProgressPercentage) End Sub
static void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e) { // Displays the operation identifier, and the transfer progress. Console.WriteLine("{0} uploaded {1} of {2} bytes. {3} % complete...", (string)e.UserState, e.BytesSent, e.TotalBytesToSend, e.ProgressPercentage); } static void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e) { // Displays the operation identifier, and the transfer progress. Console.WriteLine("{0} downloaded {1} of {2} bytes. {3} % complete...", (string)e.UserState, e.BytesReceived, e.TotalBytesToReceive, e.ProgressPercentage); }

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に収録されているすべての辞書からWebClient.DownloadProgressChanged イベントを検索する場合は、下記のリンクをクリックしてください。

- WebClient.DownloadProgressChanged イベントのページへのリンク