Set IsBackground to true : Background Thread : Thread C# Examples


C# Examples » Thread » Background Thread »

 

Set IsBackground to true









    
using  System;
using  System.Collections.Generic;
using  System.Text;
using  System.Threading;

public  class  Printer  {
        public  void  PrintNumbers()  {
                Console.WriteLine("->  {0}  is  executing  PrintNumbers()",  Thread.CurrentThread.Name);
                Console.Write("Your  numbers:  ");
                for  (int  i  =  0;  i  <  10;  i++)  {
                        Console.Write(i  +  ",  ");
                        Thread.Sleep(2000);
                }
                Console.WriteLine();
        }
}
class  Program  {
        static  void  Main(string[]  args)  {
                Printer  p  =  new  Printer();
                Thread  bgroundThread  =  new  Thread(new  ThreadStart(p.PrintNumbers));
                bgroundThread.IsBackground  =  true;

                bgroundThread.Start();
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Thread
» Background Thread