更新后台工作者的标签内容

更新后台工作者的标签内容

本文介绍了更新后台工作者的标签内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在后台工作程序中运行的进程。

i需要实现另一个DownloadProgressChangedEventHandler用于下载文件的进程并需要在UI上显示进度百分比。完整代码在类文件中



代码示例



I have a Process running in background worker .
i need to implement another DownloadProgressChangedEventHandler for Downloading Process of the file and need to show Progress in percentage on UI.Complete Code is in Class file

Code sample

public void _backgroundWorkerDoWork(object sender, DoWorkEventArgs e)
       {





一些代码......

_backgroundWorker.ReportProgress(1);



一些代码......

_backgroundWorker.ReportProgress(10);





Some Code ......
_backgroundWorker.ReportProgress(1);

Some Code ......
_backgroundWorker.ReportProgress(10);

_wbClient = new WebClient();
             _wbClient.DownloadFile(SeverPath +FileName, DownLoadedFilePath +FileName);









}







需要显示使用





}



Need to show download Progreess of Webclient using

webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
              webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);




$ b GUI上$ b





请帮助..




on GUI

Please help..
.

推荐答案

new DownloadProgressChangedEventHandler(ProgressChanged)



to

new DownlaodProgressChangedEventHandler(DownloadProgressChanged)



所以方法名称不会干扰其他 ProgressChanged 方法。



然后实现


so the method name doesn''t interfere with the "other" ProgressChanged method.

Then implement

public void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
    DownloadProgressBar.Value = e.ProgressPercentage;
}



[/编辑]


[/Edit]


这篇关于更新后台工作者的标签内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:54