Click here to Skip to main content
14,606,151 members
Rate this:
Please Sign up or sign in to vote.
I'm being afraid if a mass usage of BackgroundWorker control in a C# program will make the program slow and poorly responsible. So tell me if there is any such or any other problem if BackgroundWorker control used massively?
BillWoodruff 3-Nov-11 22:24pm
You have two excellent answers here; my one comment is that: to really reply to your question you need to explain what "massively" and "mass usage" mean.

"Mass usage" could mean using a lot of different threads via BackGroundWorker(s). "Massively" could mean using one BackGroundWorker that made heavy demand on CPU bandwidth.

Please specify the scenario.
[no name] 4-Nov-11 3:16am
Its "Mass usage" scenario from your comment. Otherwise, if a BGW that made heavy demand on CPU bandwidth, it will make the program slow indeed.
Rate this:
Please Sign up or sign in to vote.

Solution 1

I believe that BackgroundWorkers (and .Net 4 Tasks) use a thread pool, and will make appropriate use of threads. Of course, if you're trying to do too much at once the program will become slow – that's true however you divide up the work. But I don't think BackgroundWorkers will give you massive overhead problems.
[no name] 3-Nov-11 8:39am
Agreed. There is a point when adding more threads doesn't give you any returns and starts to have negative impacts on performance
DaveyM69 3-Nov-11 10:39am
Correct - 5.
Rate this:
Please Sign up or sign in to vote.

Solution 2

The main reason a background worker would have a bad effect on performance would be too much communication between the background process and the main thread (for ex. calling ReportProgress too often or locking objects too much).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100