There are few simple things you can do.
You could use Thread.Join
to see if the thread has ended.
var thread = new Thread(SomeMethod);
thread.Start();
while (!thread.Join(0)) // nonblocking
{
// Do something else while the thread is still going.
}
And of course if you do not specify a timeout parameter then the calling thread will block until the worker thread ends.
You could also invoke a delegate or event at the end of entry point method.
// This delegate will get executed upon completion of the thread.
Action finished = () => { Console.WriteLine("Finished"); };
var thread = new Thread(
() =>
{
try
{
// Do a bunch of stuff here.
}
finally
{
finished();
}
});
thread.Start();