I am sure a responsive UI is something that everyone strives for and the reccomended way to do stuff is to use the BackgroundWorker for this.
Do you find it easy to work with ? Do you use it often ? Or do you have your own frameworks for lengthy tasks and reporting process.
I have found that I am using it quite a lot and even using its delegates wherever I need some sort of progress reporting.
Multithreaded programming is hard to grasp in the beginning (and veterans still fail sometimes) and BackgroundWorker makes it a bit easier to use. I like the fact that BackgroundWorker has functionality which is easy to implement but even easier to wrongly implement in a subtle way, like cancellation. I use it if I have and need a progress update, so I can display a meaningful progress bar.
If not, I use a Thread (or borrow from the ThreadPool), because I don't need all the functionality of BackgroundWorker and am proficient enough with threads to start a Thread and wait for it to stop.
As for delegates for non-related tasks, I use those of the Thread classes, like plain void ThreadStart()
, or I create my own.
BackgroundWorker makes things a lot easier. One thing I found the hard way is Backgroundworker itself has thread affinity even though it is supposed to hide the thread switching problem. It does not automatically switch to the UI thread in every case. It needs to be created and run from the UI thread for thread switching to happen properly.
I use it quite often for tasks such as progress indication and background data loading\processing.
Recently i found use case that is not supported out of box. It's "Overridable Task". However Patric Smacchia come up with nice solution.
I've used it once and was quite happy with it. Often, there is no need for "big" multithreading, but only for 2 Threads (UI and Worker), and it works really well without having to worry too much about the underlying Threading Logic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With