ThreadStart job = () => { Console.WriteLine("Hello World!"); }; Thread thread = new Thread(job); thread.Start();
public void Calculate(int x, int y) { ThreadStart operation = () => { int result = x * y; Console.WriteLine($"Result of calculation: {result}"); }; Thread thread = new Thread(operation); thread.Start(); }In this example, we define a public method called Calculate that takes two integers as arguments. Inside the method, we create a new ThreadStart delegate called "operation", which calculates the product of the two integers and prints the result to the console. We then create a new thread, passing the operation delegate to the constructor, and start the thread. Package/Library: System.Threading