110,533
社区成员
发帖
与我相关
我的任务
分享
public void updateProcess(Label l)
//.........
pdh = new ProgressDialogHelper();
pdh.ShowProgress(() =>
{
foreach (string runjob in runList)
{
//后台任务执行
l.Content ="加载中";//修改时出错
decimal process = (decimal)i / (decimal)runList.LongCount();
Console.WriteLine("P:" + p);
if (process >= 1)
{
process = 1;
}
pdh.SetValue((double) process * 100);
pdh.SetMessage("当前进度 :" + process);
}
pdh.CloseProgressDialog();
});
class ProgressDialogHelper{
//.....
public void ShowProgress(Action workAction)
{
this.Worker = new Thread(new ThreadStart(workAction));
this.ProDialog = new ProgressDialog();
Worker.Start();
ProDialog.ShowDialog();
}
this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
{ pdh.ShowProgress(() =>
{
foreach (string runjob in runList)
{
l.Content ="加载中";
//..........................................
this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
{
this.lbInfo.Content = 进度值;
}));