Attempting To Understand “Common” async Deadlock with ASP.NET and HttpClient()

后端 未结 1 1999
广开言路
广开言路 2021-01-03 09:09

After running into a \"common\" async deadlock and getting further understanding from Async Best Practices I tried simulating the issue in ASP.NET in an attempt to figure ou

1条回答
  •  伪装坚强ぢ
    2021-01-03 09:58

    The reason why api/DeadLock/HttpDeadLock is not dead-locking is because within that code you are not awaiting for any task.

    You are instead blocking the thread by synchronosuly waiting on the task by calling Task.Result.

    Dead-locks when implementing this sort of patterns usually come up with a combination of async-await and Task.Wait/Task.Result combination.

    0 讨论(0)
提交回复
热议问题