Thread.IsAlive : Thread « System.Threading « C# / C Sharp by API






Thread.IsAlive

  

using System;
using System.Threading;

public class ThreadState {
    static void WorkerFunction() {
        for (int i = 1; i < 50000; i++) {
            Console.WriteLine("Worker: " + Thread.CurrentThread.ThreadState);
        }
    }


    static void Main() {
        string ThreadState;
        Thread t = new Thread(new ThreadStart(WorkerFunction));
        t.Start();
        while (t.IsAlive) {
            Console.WriteLine("Still waiting. I'm going back to sleep.");
            Thread.Sleep(200);
        }
        Console.WriteLine(t.ThreadState);
    }
}

   
    
  








Related examples in the same category

1.new Thread()
2.Thread.Abort()
3.Thread.AllocateDataSlot
4.Thread.AllocateNamedDataSlot
5.Thread.CurrentContext
6.Thread.CurrentCulture
7.Thread.CurrentThread
8.Thread.GetData
9.Thread.GetHashCode()
10.Thread.Interrupt()
11.Thread.IsBackground
12.Thread.Join()
13.Thread.Priority
14.Thread.ResetAbort()
15.Thread.SetData
16.Thread.Sleep
17.Thread.Start
18.Thread.ThreadState