CPallini answered you, but the polling of the thread for status is a sign of really wrong design.
In some situations, you need a blocking call
System.Threading.Thread.Join
. The calling thread will be put in wait state, sleeping without wasting any CPU cycles, until awakened by completion. Please see:
http://msdn.microsoft.com/en-us/library/system.threading.thread.join.aspx[
^].
I see you already trying "
if (working) thread.Join()
", but this is pointless, really. Explain what you are trying to achieve, the purpose of it.
In other cases, it's the best for a thread to notify other threads on completion. How? It depends. Please see my comments to Solution 2.
—SA