What is the difference between BackgroundWorker
and Thread
? In my application I am using a messaging system that communicates with the database regularly. Which one would I want to use here: BackgroundWorker
or Thread
?
What is the difference between BackgroundWorker
and Thread
? In my application I am using a messaging system that communicates with the database regularly. Which one would I want to use here: BackgroundWorker
or Thread
?
A BackgroundWorker is a ready to use class in WinForms allowing you to execute tasks on background threads which avoids freezing the UI and in addition to this allows you to easily marshal the execution of the success callback on the main thread which gives you the possibility to update the user interface with the results. It also gives the possibility to track progress and cancel the task. It uses threads from the thread pool.
On the other hand a Thread is a class allowing you to simply execute some task on a new thread. It's a much more basic concept.