【发布时间】:2014-11-30 16:08:08
【问题描述】:
我可能很愚蠢但是如何解决以下问题? 当我想下载许多文件时,我使用链接列表和线程化 WebClient.DownloadFileAsync。但我希望在此过程中更新我的 UI (ProgressBar),所以我使用 this answer 来部分解决问题。
但是当我应用这部分代码时
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
this.Dispatcher.BeginInvoke((Delegate MethodInvoker)
{
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
thebar.Value = int.Parse(Math.Truncate(percentage).ToString());
});
}
我得到“'System.Delegate' is a 'type' but is used like a 'variable'”错误。
【问题讨论】:
标签: c# wpf multithreading downloadfileasync