Insert code that is appropriate for your platform where I have added comments below:
{
// Create event visible by second thread to be signalled on completion
Launch_Secondary_Thread();
// Wait for event to be signalled
}
{
Do_Something_Once();
// set the event state to signalled so that 1st thread knows to continue working
while (not_important_condition) {
Do_Something_Inside_Loop();
}
}
Make sure that the event DOES get signalled, even if 2nd thread exits abnormally after an exception or other error. If not, your 1st thread will never wake up. Unless you can put a timeout on the wait.
Steve Townsend
2010-09-07 16:06:05