why does the method AwakeTest
take 3 seconds instead of one
public static async void AwakeTest()
{
var Do1 = Sleep(1, 1);
var Do2 = Sleep(1, 2);
var Do3 = Sleep(1, 3);
await System.Threading.Tasks.Task.WhenAll(Do1, Do2, Do3);
Console.WriteLine(await Do1);
Console.WriteLine(await Do2);
Console.WriteLine(await Do3);
}
private static async System.Threading.Tasks.Task<int> Sleep(int Seconds, int ID)
{
if (Seconds < 0)
{
throw new Exception();
}
System.Threading.Thread.Sleep(Seconds * 1000);
return ID;
}