DownloadProgressChangedEventArgs 类    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 WebClient 的 DownloadProgressChanged 事件提供数据。
public ref class DownloadProgressChangedEventArgs : System::ComponentModel::ProgressChangedEventArgspublic class DownloadProgressChangedEventArgs : System.ComponentModel.ProgressChangedEventArgstype DownloadProgressChangedEventArgs = class
    inherit ProgressChangedEventArgsPublic Class DownloadProgressChangedEventArgs
Inherits ProgressChangedEventArgs- 继承
示例
下面的代码示例演示如何为 DownloadProgressChanged 事件设置事件处理程序。
// 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) |