C# delegates to update the UI from a thread

The Following enables a thread to update the main UI using a delegate.  In this case MyTextBox.Text has an “x” added to its text property.

Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => this.MyTextBox.Text += "x"));

Leave a Reply

Your email address will not be published. Required fields are marked *