static async Task AsyncAwait() { var asyncAwaitExamples = new AsyncAwaitExamples(); await asyncAwaitExamples.DownloadHtmlAsync("https://docs.microsoft.com/en-gb/"); var html = await asyncAwaitExamples.GetStringAsync("https://docs.microsoft.com/en-gb/"); Console.WriteLine(html.Substring(0, 10)); // If you need, you can postpone the execution of you task var getHtmlTask = asyncAwaitExamples.GetStringAsync("https://docs.microsoft.com/en-gb/"); // Do something... Console.WriteLine("Waiting..."); var html2 = await getHtmlTask; Console.WriteLine(html2.Substring(0, 10)); }
public void MenuOpt1() { AsyncAwaitExamples.AsyncEx2Main(); }
public void MenuOpt0() { AsyncAwaitExamples.AsyncEx1Main(); }