Depends on what you would like to accomplish. What form of communication are you trying to facilitate?
If I were to guess, what you really want is to simply report [or display] your worker results in your application. If this is the case, then in a typical WPF application you have a view model, say
public class AwesomeViewModel : INotifyPropertyChanged
{
// if small fixed number, otherwise, you could use
// an ObservableCollection<T>
public string WorkerResultA { ... }
public string WorkerResultB { ... }
public string WorkerResultC { ... }
}
which is data-bound to your WPF controls. You can simply pass a reference of your view model to each worker thread and they update the class without requiring blocking\waiting on Gui thread. In this manner, each worker reports its results when it completes without intervention from anyone else. This is optimal.
Of course, if you go ahead and do just this, you run into another completely different issue. Which, fyi, is resolvable via Dispatcher. One possible solution here.
As for BackgroundWorker
versus explicit Thread
control, that is up to you. There are advantages to both, but remember you already have functional code written. That, and in my personal opinion, BackgroundWorker
isn't particularly useful.
If you really absolutely positively must implement a more sophisticated synchronization model, then I highly recommend you brush up on ManualResetEvent its cousin AutoResetEvent, Semaphore, keyword lock and concurrent programming in general. Sorry, no shortcuts there :)
Hope this helps!