How do I handle async operations in Startup.Configure?

后端 未结 4 514
暗喜
暗喜 2021-02-01 11:57

In my ASP.NET 5 app, I want to load some data from Azure into a cache inside my Startup.Configure method. The Azure SDK exposes async methods exclusively. Typically, calling an

4条回答
  •  一生所求
    2021-02-01 12:15

    The answers in here do not always work correctly if your async code makes further async calls, especially if those are callbacks, then you may find the code deadlocks.

    This has happens on numerous occasions for me and have used the Nito.AsyncEx with great effect.

    using Nito.AsyncEx;
    
    AsyncContext.Run(async () => { await myThing.DoAsyncTask(); });
    

提交回复
热议问题