using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace Multithreading { public static class BackgroundThread { // Using a background thread //Thread method public static void ExampleThreadMethod() { for (int x = 0; x < 10; x++) { Console.WriteLine("ExampleThreadMethod: {0}", x); //Thread.Sleep(1000)? //Sleep one second Thread.Sleep(1000); } } //Main method public static void Main(string[] args) { Thread thread = new Thread(new ThreadStart(ExampleThreadMethod)); //Define thread is as background thread thread.IsBackground = true; thread.Start(); } } }
//Define thread is as Background thread thread.IsBackground = true;
//Define thread is as Foreground thread thread.IsBackground = false;
Comments