thread.IsAlive : Thread Start « Thread « C# / CSharp Tutorial






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);
    }
}








20.2.Thread Start
20.2.1.An alternate way to start a thread: start a thread in its own constructor
20.2.2.thread.IsAlive
20.2.3.Simple Thread with ThreadStart