Spawning BackgroundWorkers
Posted
by washtik
on Stack Overflow
See other posts from Stack Overflow
or by washtik
Published on 2010-04-19T00:28:20Z
Indexed on
2010/04/19
0:33 UTC
Read the original article
Hit count: 607
We have a business case that would be perfect for multiple BackgroundWorkers.
As an example, we have a form with a "Save" button on it. Normally we would run all the save commands (Save is an example) synchronously and then close the form. We would like to now split the work onto separate threads using backgroundworker.
We will loop through each "Save" required (could be many and/or different number of commands that need executing) creating a BackgroundWorker for each command required.
The question is ... how do we wait for ALL the BackgroundWorkers to complete before we close the form. We understand how to wait for a single BackgroundWorker to complete but when we have X number of BackgroundWorkers operating, how do we wait until all are complete before closing the UI form?
© Stack Overflow or respective owner