I have a parent thread (non-UI) which creates some child threads to do some jobs - at some point the parent must wait for certain tasks to be completed by the child thread - this does not mean the child is finished but only that it has reached a certain point and the parent can now continue processing ...
To illustrate please refer to the code below, obviously this isn't what my children do but it shows what I am trying to accomplish. Recall that none of these are UI threads...
// Parent Thread
Thread childThread = new Thread(new ThreadStart(Manage));
childThread.IsBackground = true;
childThread.Name = "NamedPipe Manager";
childThread.Start();
while (true)
{
... do some work ...
// wait for signal from MainThread to proceed //
... do more work
}
// Child Thread
private void Manage()
{
... do some work ...
... call some functions ...
// SIGNAL TO PARENT THAT IT CAN CONTINUE //
... do more work ...
... call more functions ...
}
Any one have any suggestions on how I can accomplish this task in a thread-safe manner? Any help would be much appreciated. Thanks,