这是我的代码(Simple Downloader):
public void DownloadFile(string urlAddress, string location)
{
using (webClient = new WebClient())
{
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
Uri URL = urlAddress.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ? new Uri(urlAddress) : new Uri("http://" + urlAddress);
try
{
webClient.DownloadFileAsync(URL, location);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
&安培;这是我的问题:
如何在我的int RowNumber
活动中添加额外参数(ProgressChanged
)?我的意思是这样的:
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e, int RowNumber)
{
// Other codes here
}
&安培;这是VS2010给我的错误:
' ProgressChanged'匹配代表 ' System.Net.DownloadProgressChangedEventHandler'
我应该覆盖DownloadProgressChangedEventHandler
吗?!怎么样?!
感谢您帮助我。
答案 0 :(得分:2)
你应该改变这个:
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
使用:
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler((sender, e) => ProgressChanged(sender, e, RowNumber));