Skip to content

Instantly share code, notes, and snippets.

@ArturKarbone
Created October 15, 2016 10:04
Show Gist options
  • Save ArturKarbone/e99bf04b95100cd69f915d3008bc30c7 to your computer and use it in GitHub Desktop.
Save ArturKarbone/e99bf04b95100cd69f915d3008bc30c7 to your computer and use it in GitHub Desktop.
async Main gotchas
public class Program
{
//Not Awaited
//public static void Main(string[] args) => AsyncMain(args);
//Awaited #1
//public static void Main(string[] args) => AsyncMain(args).GetAwaiter().GetResult();
//Awaited #2
public static void Main(string[] args) => AsyncMain(args).Wait();
public static async Task AsyncMain(string[] args)
{
var content = await new HttpClient()
.GetStringAsync("https://github.com");
Console.WriteLine(content);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment