How to run method in separate thread






3.50/5 (3 votes)
Multithreading
Here is the main method which can run a method in a separate thread:
private static void RunMethodInSeparateThread(Action action)
{
var thread = new Thread(new ThreadStart(action));
thread.Start();
}
Here is how to use this method:
private static void Method1()
{
//Method1 implementation
}
private static void Method2()
{
//Method2 implementation
}
static void Main(string[] args)
{
RunMethodInSeparateThread(Method1);
RunMethodInSeparateThread(Method2);
}