using System.Diagnostics;
using System.Threading.Tasks;
public static void Main()
Console.WriteLine("== Await before cycle");
Console.WriteLine("== Await in cycle");
public static async Task Method() {
Stopwatch stopWatch = new Stopwatch();
var t = await Task.Delay(1000).ContinueWith(_ => 10);
for(var i=0;i<10000000;i++) res += t;
TimeSpan ts = stopWatch.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
Console.WriteLine("RunTime " + elapsedTime);
public static async Task Method2() {
Stopwatch stopWatch = new Stopwatch();
var t = Task.Delay(1000).ContinueWith(_ => 10);
for(var i=0;i<10000000;i++) res += await t;
TimeSpan ts = stopWatch.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
Console.WriteLine("RunTime " + elapsedTime);