在这个例子中
private Task ProcessData(List<Tuple<int,string>> list, IProgress<ProgressReport> progress)
{
int index = 1;
int totalprogress = list.Count;
var progressreport = new ProgressReport();
return Task.Run(()=> {
for(int i = 0; i < totalprogress; i++)
{
Tuple<int, string> temp = list[i];
int id = temp.Item1;
string address = temp.Item2;
label_autoupdate.Text = string.Format("Processing ...{0}",address);
excuteAutoUpdate(id, address);
progressreport.PercentComplete = i++ * 100 / totalprogress;
progress.Report(progressreport);
Thread.Sleep(10);
}
// groupBox_autoupdate.Visible = false;
});
}
private async void button_update_tracking_Click(object sender, EventArgs e)
{
List<Tuple<int, string>> list = new List<Tuple<int, string>>();
//..
var progress = new Progress<ProgressReport>();
progress.ProgressChanged += (o, report) =>
{
progressBar1.Value = report.PercentComplete;
progressBar1.Update();
};
await ProcessData(list, progress);
}
我有实时的最新错误消息,但从来没有,一旦我发出电子邮件错误,它会显示覆盖名称错误,反之亦然,但如果我删除 f:ajax 组件并使用 h:commandButton 进行刷新,我正确显示了两个错误。我需要使用其他活动吗?