Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is background worker a thread? (C#)

Tags:

c#

Is background worker a thread? When should I use it?

like image 416
yonan2236 Avatar asked Aug 20 '10 02:08

yonan2236


1 Answers

Yes, it is basically like a thread, but with extra functionality (events to notify you of progress and when it finishes).

You should use it whenever you need to execute something that might take a while (e.g. a calculation, file or database reading/writing, web requests, etc.) and you don’t want the GUI to appear unresponsive while it is happening:

The BackgroundWorker class allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.

Read How to: Run an Operation in the Background for an introduction.

like image 106
Timwi Avatar answered Nov 03 '22 08:11

Timwi