class Program
{
static void Main(string[] args)
{
Run(); } public static async void Run()
{
var tasks = StartMultiWorkerTasks();
if (tasks.Length > 0)
{
await Task.WhenAll(tasks).ContinueWith(t =>
{
Console.WriteLine("done ......");
});
}
Task.WaitAll(tasks);
} /// <summary>
/// Start multi tasks
/// </summary>
/// <param name="request"></param>
/// <param name="coupleSyncResult"></param>
/// <returns></returns>
public static Task[] StartMultiWorkerTasks()
{
Task[] tasks = new Task[3];
tasks[0] = Task.Run(() => Console.WriteLine("do some thing 1...................."));
tasks[1] = Task.Run(() => Console.WriteLine("do some thing 2...................."));
tasks[2] = Task.Run(() => Console.WriteLine("do some thing 3...................."));
return tasks;
}
}