KeyVault GetSecretAsync never returns

前端 未结 5 1426
醉话见心
醉话见心 2021-01-03 10:37

The sample code for working with KeyVault inside a web application has the following code in it:

public static async Task GetSecret(string secr         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 11:14

    This generic method can be used to override the deadlock issue:

    public static T SafeAwaitResult(Func> f)
    {
        return Task.Run(async () => await f()).Result;
    }
    

    Use:

    SafeAwaitResult(() => foo(param1, param2));
    

提交回复
热议问题