Sleep Interupt Threads : Thread Interrupt « Thread « C# / CSharp Tutorial






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();
    }
  }
}
Thread Interupted








20.6.Thread Interrupt
20.6.1.Sleep Interupt Threads
20.6.2.Interrupting a Thread
20.6.3.Interrupting Threads