Thread Creationg And Starting C# with Example
using System; using System.Threading; namespace CSharpMultiThreading { class ThreadBasics { static void Main(string[] args) { int id = Thread.CurrentThread.ManagedThreadId; // Print out the ID of the executing thread. Console.WriteLine("Main() invoked on thread {0}.",id); // Create New Thread. Thread newThread = new Thread(PrintHello); // Start Newly Created Thread. newThread.Start(); } public static void PrintHello() { int id = Thread.CurrentThread.ManagedThreadId; // Print out the ID of the executing thread. Console.WriteLine("Add() invoked on thread {0}.",id); // Pause to simulate a lengthy operation. Thread.Sleep(2000); Console.WriteLine("Hello! I am 2 Second Late. Sorrrrrrrrrry!"); } } }