Executing dynamic list of Actions with parameters
问题 I'm building a list of Actions based on some other data. Each action should do a call to a method, and the list of actions should be performed in parallel. I have the following code that works just fine for parameterless methods: private void Execute() { List<Action> actions = new List<Action>(); for (int i = 0; i < 5; i++) { actions.Add(new Action(DoSomething)); } Parallel.Invoke(actions.ToArray()); } private void DoSomething() { Console.WriteLine("Did something"); } But how can I do