async provider in .net core DI
问题 I'm just wondering if it's possible to have async/await during DI. Doing the following, the DI fails to resolve my service. services.AddScoped(async provider => { var client = new MyClient(); await client.ConnectAsync(); return client; }); where as the following works perfectly fine. services.AddScoped(provider => { var client = new MyClient(); client.ConnectAsync().Wait(); return client; }); 回答1: Async/await doesn't make sense when resolving dependencies, because: Constructors can't be