Couple of times, we have a situation where we want to execute more than one methods together and in order to do that one can use Parallel class considering thread safety in mind.
public static void Function1() { Console.WriteLine("Print - F1"); }
public static void Function2() { Console.WriteLine("Print - F2"); }
public static void Function3() { Console.WriteLine("Print - F3"); }I have three different function which will be executed in random order (random because it is CPU specific to decide which thread to choose first).Below is the way to invoke all three functions together.
Parallel.Invoke(Function1, Function2, Function3);You should see output something as below:Print - F1
Print - F2
Print - F3