Reputation:
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?
Upvotes: 2
Views: 659
Reputation: 21899
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.
Upvotes: 2
Reputation: 11564
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
Upvotes: 1
Reputation: 11637
Threading.Thread.Join is what you are looking for.
Edit: Examples here
Upvotes: 15