Search code examples
c#multithreadingthread-state

How to check if Thread finished execution


I have following problem:

I want to check (C#) if a thread has finished execution, i.e. if the thread method has returned. What I do now is call Thread.Join(1), but this gives a 1 ms delay. Is there any way to simply check if a thread has finished. Inspecting Thread.ThreadState just seems too cumbersome.


Solution

  • Use the Thread.IsAlive flag. This is to give the thread status.