I’ve tried multiple times to use the multiple .net methods for multi threading. I’ve encountered the same problem every time and that is trying to change UI properties from another thread.
I’ve read online that the BackgroundWorker has a special event that can be used to relay information back to the main thread. After trying it out, it was VERY unreliable and seemed like a cheap hack. I was very disappointed. I haven’t been able to find anything about this.
Any ideas?
This isn’t really specific to .NET, even. Many user interface frameworks have thread affinity.
There are many alternatives to using BackgroundWorker, including
Control.BeginInvokefor Windows Forms or using theDispatcherfor WPF or Silverlight.If you’re using .NET 4, you can also use TaskScheduler.FromCurrentSynchronizationContext to execute any
Taskon the UI thread’s synchronization context.