Async/await in console app

// 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.


Comments

Popular posts from this blog

C# Record Serialization

Add timestamp to photo using ImageMagick

Read/write large blob to SQL Server from C#