using System.Threading.Tasks;
public static int Counter = 1;
public static void Main()
System.Threading.Thread.Sleep(1000);
public static async Task<string> Do()
var x = await DoWithYield(awaited: true);
Console.WriteLine($"{Counter++} Main with await.");
DoWithYield(awaited: false);
Console.WriteLine($"{Counter++} Main without await.");
public static async Task<string> DoWithYield(bool awaited)
await Task.FromResult(0);
Console.WriteLine($"{Counter++} If main does await, we should see Main after this message.");
Console.WriteLine($"{Counter++} If main does not await, then this runs at a non-deterministic time.");