I have a TreeView that has many nodes. I have a background worker that iterates through the nodes and either adds nodes, or updates the Checked property. Is it possible to update the node from my background thread if I pass the node to the background thread as a reference (I’m using the SyncronizationContext class to update controls that were created on the main thread)? Just curious if I can or not because it’s ALOT of programming change if I can/can’t do it from my background thread.
Share
You can’t update controls outside the UI thread. But you can invoke some function on the UI thread using
Application.Current.Dispatcher.Invoke(for WPF) orControl.Invoke(for WinForms). You should remember that those operations will be executed on the main thread and can make your application unresponsive if you try to do something time consuming here