using System; using System.Threading; public class Example { public static void Main() { ThreadStart thStart = new ThreadStart(PrintMessage); Thread newThread = new Thread(thStart); newThread.Start(); } public static void PrintMessage() { // Perform some action Console.WriteLine("Hello from a new thread!"); } }
using System; using System.Threading; public class Example { public static void Main() { Thread newThread = new Thread(() => { PrintMessage(); }); newThread.Start(); } public static void PrintMessage() { // Perform some action Console.WriteLine("Hello from a new thread!"); } }Both examples use the standard C# library, no additional package is required.