在Silverlight中,如何在Main Dispatch Thread上调用操作?

Eri*_*ric 5 .net silverlight multithreading

在WinForms UserControl中,我会通过从任何控件的方法调用this.BeginInvoke()将数据传递给主GUI线程.什么是Silverlight UserControl中的等价物?

换句话说,我如何获取任意工作线程提供的数据并确保它在主显示线程上得到处理?

Tim*_*ell 6

使用UserControl类上的Dispatcher属性.

private void UpdateStatus()
{
  this.Dispatcher.BeginInvoke( delegate { StatusLabel.Text = "Updated"; });
}
Run Code Online (Sandbox Code Playgroud)