HttpClient.GetAsync(…) never returns when using await/async

前端 未结 6 775
[愿得一人]
[愿得一人] 2020-11-22 12:22

Edit: This question looks like it might be the same problem, but has no responses...

Edit: In test case 5 the task appears to be st

6条回答
  •  粉色の甜心
    2020-11-22 13:11

    These two schools are not really excluding.

    Here is the scenario where you simply have to use

       Task.Run(() => AsyncOperation()).Wait(); 
    

    or something like

       AsyncContext.Run(AsyncOperation);
    

    I have a MVC action that is under database transaction attribute. The idea was (probably) to roll back everything done in the action if something goes wrong. This does not allow context switching, otherwise transaction rollback or commit is going to fail itself.

    The library I need is async as it is expected to run async.

    The only option. Run it as a normal sync call.

    I am just saying to each its own.

提交回复
热议问题