Async/await in console app

Posted by Joe Enos on May 12, 2021 · 1 min read

// PM> Install-Package Nito.AsyncEx

using Nito.AsyncEx;

class Program {
static void Main(string[] args) {
AsyncContext.Run(() => MainAsync(args));
}

static async void MainAsync(string[] args) {
// await Something...
}
}

This was an answer on StackOverflow by async/await superstar and blogger Stephen Cleary, who wrote the referenced NuGet package.