Spawning BackgroundWorkers
- by washtik
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?