アクションを含むタスクに複数のパラメータを追加したい。既存のスタック オーバーフローの質問を確認しました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";
}
非同期メソッドのアクションを作成する方法と、アクションをタスクに追加する方法を教えてください。