首先要了解的是,Dispatcher并非旨在运行长时间阻止操作(例如从WebServer检索数据…)。当您要运行将在UI线程上执行的操作(例如更新进度条的值)时,可以使用Dispatcher。
您可以做的是在后台工作程序中检索数据,并使用ReportProgress方法在UI线程中传播更改。
如果确实需要直接使用Dispatcher,则非常简单:
Application.Current.Dispatcher.BeginInvoke(
DispatcherPriority.Background,
new Action(() => this.progressBar.Value = 50));