views:

1477

answers:

1

In a WinForms UserControl, I would pass data to the main GUI thread by calling this.BeginInvoke() from any of the control's methods. What's the equivalent in a Silverlight UserControl?

In other words, how can I take data provided by an arbitrary worker thread and ensure that it gets processed on the main displatch thread?

+4  A: 

Use the Dispatcher property on the UserControl class.

private void UpdateStatus()
{
  this.Dispatcher.BeginInvoke( delegate { StatusLabel.Text = "Updated"; });
}
Timothy Lee Russell