thread.IsAlive : Thread Start : Thread C# Examples


C# Examples » Thread » Thread Start »

 

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




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Thread
» Thread Start