我想在包含 Action 的任务中添加多个参数。我查看了现有的堆栈溢出问题Create a Task with an Action<T>
请帮助我如何在 Task 的 Action 方法中传递多个参数
Action<string, int> action = (string msg, int count) =>
{
Task.Factory.StartNew(async () =>
{ await LoadAsync(msg, count); });
};
Task task = new Task(action, ....);
行动方法是
public static async Task<string> LoadAsync(string message, int count)
{
await Task.Run(() => { Thread.Sleep(1500); });
Console.WriteLine("{0} {1} Exceuted Successfully !", message ?? string.Empty, (count == 0) ? string.Empty : count.ToString());
return "Finished";
}
请帮助我如何创建异步方法的操作以及如何将操作添加到任务中。