DownloadProgressChangedEventArgs 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供 DownloadProgressChanged 的 WebClient 事件的資料。
public ref class DownloadProgressChangedEventArgs : System::ComponentModel::ProgressChangedEventArgs
public class DownloadProgressChangedEventArgs : System.ComponentModel.ProgressChangedEventArgs
type DownloadProgressChangedEventArgs = class
inherit ProgressChangedEventArgs
Public Class DownloadProgressChangedEventArgs
Inherits ProgressChangedEventArgs
- 繼承
範例
下列程式代碼範例示範如何設定 事件的事件處理程式 DownloadProgressChanged 。
// Sample call : DownLoadFileInBackground4 ("http://www.contoso.com/logs/January.txt");
void DownLoadFileInBackground4( String^ address )
{
WebClient^ client = gcnew WebClient;
Uri ^uri = gcnew Uri(address);
// Specify a DownloadFileCompleted handler here...
// Specify a progress notification handler.
client->DownloadProgressChanged += gcnew DownloadProgressChangedEventHandler( DownloadProgressCallback4 );
client->DownloadFileAsync( uri, "serverdata.txt" );
}
static void DownloadProgressCallback4(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);
}
// Sample call : DownLoadFileInBackground4 ("http://www.contoso.com/logs/January.txt");
public static void DownLoadFileInBackground4(string address)
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
// Specify a DownloadFileCompleted handler here...
// Specify a progress notification handler.
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback4);
client.DownloadFileAsync(uri, "serverdata.txt");
}
private static void DownloadProgressCallback4(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);
}
' Sample call : DownLoadFileInBackground4 ("http://www.contoso.com/logs/January.txt");
Public Shared Sub DownLoadFileInBackground4(ByVal address As String)
Dim client As WebClient = New WebClient()
' Specify a DownloadFileCompleted handler here...
' Specify a progress notification handler.
AddHandler client.DownloadProgressChanged, AddressOf DownloadProgressCallback4
Dim uri as Uri = New Uri(address)
client.DownloadFileAsync(uri, "serverdata.txt")
End Sub
Private Shared Sub DownloadProgressCallback4(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
備註
這個類別的實體會傳遞至 DownloadProgressChangedEventHandler。
屬性
BytesReceived |
取得接收的位元組數目。 |
ProgressPercentage |
取得非同步工作的進度百分比。 (繼承來源 ProgressChangedEventArgs) |
TotalBytesToReceive |
取得 WebClient 資料下載作業中的位元組總數。 |
UserState |
取得唯一的使用者狀態。 (繼承來源 ProgressChangedEventArgs) |
方法
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
GetType() |
取得目前執行個體的 Type。 (繼承來源 Object) |
MemberwiseClone() |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
ToString() |
傳回代表目前物件的字串。 (繼承來源 Object) |