Set IsBackground to true : Background Thread « Thread « C# / CSharp Tutorial






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








20.9.Background Thread
20.9.1.Move thread to background
20.9.2.Test foreground / worker behaviors
20.9.3.Set IsBackground to true