Single Child thread notifying Parent to indicate that it is finished so Parent can launch another child [C#]
<p>I have a PARENT thread responsible for performing jobs, for each job it launches a CHILD thread to do the work - however it should never be allowed to launch more then one at a time (single child). For example in the case where there are 10 jobs to do it should do them one-after-another - therefore the PARENT needs to be know when each job has completed so it can launch the next pending one.</p>

<p>Typically I would just .Join() or a WaitHandle to accomplish this task - except that in this case I cannot block the Parent thread as it has other responsibilites that need to be performed while waiting for the child to complete ...</p>

<p>Allow me to illustrates:</p>

<pre><code>class Parent
{

private Thread threadJob;

public Parent()
    {
    // this is where the main loop occurs
    while (bRun)
        {

        // This is where I need help ... how can I know that threadJob is not currently performing a task?
        // is there an event it can fire to let Parent know that it is done? A flag it can set?
        if (threadJob child is not currently running a job)
            {
            threadJob = new Thread(new ThreadStart(PerformWork));
            threadJob.IsBackground = true;
            threadJob.Start();
            }

        .. do other work ...
        .. keep doing other work ...

        }
    }
};
</code></pre>

<p>Any help or advice would be much appreciated.
Thanks,</p>
