September 2nd, 2017  // Posted in C#, async

One of the pain points of the async/await feature from the beginning was inability to mark console application’s Main method as async and to await other methods without using workarounds. Not anymore!

With the release of C# 7.1, Main method can be async as well. This is just a syntactic sugar - compiler will rewrite the code to apply the same workarounds as before, but at leas for developers code will look much nicer:

static async Task Main(string[] args)
{
   ...
   await DoWork();
   ...
}
blog comments powered by Disqus