Async and Await with HttpWebRequest.GetResponseAsync

后端 未结 1 1194
借酒劲吻你
借酒劲吻你 2020-12-17 08:35

I am trying to use Async and Await when making a web request and am finding that it never gets past the await line. I am doing this from a Metro app, but I also verified th

1条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-17 09:26

    I suspect that further up your call stack, you're either calling Wait or Result on the returned Task. This will cause a deadlock, as I describe on my blog.

    Follow these best practices to avoid the deadlock:

    1. Don't block on async code; use async all the way down.
    2. In your "library" methods, use ConfigureAwait(false).

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