C# Spawn Multiple Threads for work then wait until all finished
- by pharoc
just want some advice on "best practice" regarding multi-threading tasks.
as an example, we have a C# application that upon startup reads data from various "type" table in our database and stores the information in a collection which we pass around the application. this prevents us from hitting the database each time this information is required.
at the moment the application is reading data from 10 tables synchronously. i would really like to have the application read from each table in a different thread all running in parallel. the application would wait for all the threads to complete before continuing with the startup of the application.
i have looked into BackGroundWorker but just want some advice on accomplishing the above.
Does the method sound logical in order to speed up the startup time of our application
How can we best handle all the threads keeping in mind that each thread's work is independent of one another, we just need to wait for all the threads to complete before continuing.
i look forward to some answers