C# Spawn Multiple Threads for work then wait until all finished

Posted by pharoc on Stack Overflow See other posts from Stack Overflow or by pharoc
Published on 2010-03-27T10:33:18Z Indexed on 2010/03/27 10:43 UTC
Read the original article Hit count: 178

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.

  1. Does the method sound logical in order to speed up the startup time of our application
  2. 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

© Stack Overflow or respective owner

Related posts about backgroundworker

Related posts about c#