I have list of methods and need to make parallelize them. How to do that in C#? I see that there is a Parallel namespace?How to use it?
method1()
method2()
method3()
method4()
I have list of methods and need to make parallelize them. How to do that in C#? I see that there is a Parallel namespace?How to use it?
method1()
method2()
method3()
method4()
Parallel.Invoke method:
Parallel.Invoke(
    () => method1(),
    () => method2(),
    () => method3(),
    () => method4()
)
Add namespace System.Threading.Tasks
 
    
    You can create a list of Action delegate where each delegate is a call to a given method:
List<Action> actions = new List<Action>
{
     method1,
     method2,
     method3
};
And then use Parallel.ForEach to call them in parallel:
Parallel.ForEach(actions, action => action());
