views:

236

answers:

4

I have a console application that inits 4 theads to perform a long task. I want my program to wait until the threads are complete, and then complete the program execution. Is there a way to stop the program from executing, letting the threads complete their job?

+14  A: 

Threading.Thread.Join is what you are looking for.

Edit: Examples here

Pondidum
+1  A: 

Depending upon how you're starting the 4 threads then WaitHandle.WaitAll might be a good place to start...

http://msdn.microsoft.com/en-us/library/z6w25xa6.aspx

Martin Peck
+1  A: 

Thread.Join is what you want.

Visage
+2  A: 

Load your application after those threads are joined e.g:

Thread1.join();
Thread2.join();
Thread3.join();
Thread4.join();


startApplication();

If you could provide me in more detail i can help you better.

Aizaz