// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Threading; using System.Threading.Tasks; namespace E { public class Program { private static async Task Demo() { Console.WriteLine("Before"); await Task.Delay(5000); Console.WriteLine("After"); return 42; } private static void Test() { Console.WriteLine(DateTime.Now.Ticks / 10000); Task t = Demo(); Console.WriteLine(DateTime.Now.Ticks / 10000); Thread.Sleep(1000); Console.WriteLine(DateTime.Now.Ticks / 10000); int v = t.Result; Console.WriteLine(DateTime.Now.Ticks / 10000); } public static void Main(string[] args) { Test(); } } }