Sleep Interupt Threads : Thread Interrupt : Thread C# Examples


C# Examples » Thread » Thread Interrupt »

 

Sleep Interupt Threads









    
using  System;
using  System.Threading;

public  class  MainClass
{
    public  static  int  Main()
    {
        Thread  X  =  new  Thread(new  ThreadStart(Sleep));

        X.Start();

        X.Interrupt();

        X.Join();
        return  0;
    }
    public  static  void  Sleep()
    {
        try
        {
            Thread.Sleep(Timeout.Infinite);
        }catch  (ThreadInterruptedException  e){
            Console.WriteLine("Thread  Interupted");
        }catch(ThreadAbortException  e){
            Thread.ResetAbort();
        }
    }
}
    
   
  
   



Output

Thread Interupted


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Thread
» Thread Interrupt