【发布时间】:2012-10-11 06:59:34
【问题描述】:
我在 WPF 中使用后台工作者。问题在于它没有报告进度。它只是在完成任务时更新 ProgressBar。我想在后台任务运行时定期更新它。这是我的示例代码。
bworker_doWork(...)
{
BindData();//this is database operation which binds data to datagrid.
}
bWorker_ProgressChanged(...)
{
progressBar.Value=e.ProgressPercentage;//it doesnt update this value
}
bWorker_RunWorkerCompleted(..)
{
progressBar.Value=100;//max value. control comes here and updates the progress to max value.
}
【问题讨论】:
-
你在哪里设置 ProgressPercentage?能否提供更多代码?
-
您必须在代码中的某处调用 ReportProgress。看看这个 SO 问题。 stackoverflow.com/questions/854548/…
标签: wpf progress-bar backgroundworker progress