using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp2
{
public class Program
{
static int Main(string[] args)
{
Console.WriteLine("start...");
Test();
Thread.Sleep(15000);
Console.WriteLine("end...");
return 0;
}
async static void Test()
{
Console.WriteLine("Begin Test");
for (int i = 0; i < 3; i++)
{
await TestTask(i);
}
Console.WriteLine("End Test");
}
static Task TestTask(int num)
{
return Task.Run(() =>
{
Console.WriteLine("Begin Task:" + num.ToString());
Thread.Sleep(5000);
Console.WriteLine("End Task:" + num.ToString());
});
}
}
}