Thread1/2: do TotalThreads– on their exit
int TotalThreads = 2;
void AsyncFunc() {
// run thread for Func()
}
void Func() {
// run Thread1
// run Thread2
while(TotalThreads > 0) { /* do nothing */ }
// some code
}
is that bad design?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are creating new threads using System.Threading.Thread, you can use Thread.Join on each thread instance. This will block the main thread until the running threads have completed.
Based on your comments, this example should match your requirement.