HttpWebRequest synchronous on Windows Phone 8

前端 未结 2 405
忘了有多久
忘了有多久 2021-01-21 11:39

In order to design / reuse a library usable both for WPF apps, Windows Phone 8 apps and later Windows 8 / RT apps, we need to make some HttpWebRequest call, preferably synchrono

相关标签:
2条回答
  • 2021-01-21 12:14

    The HttpWebRequest use UI thread to process a request, don't ask me why.

    So if you try to wait a result by lock the UI thread, you will get a deadlock condition, because you lock UI thread until request is not complete and request will not be complete while UI thread is locked.

    0 讨论(0)
  • 2021-01-21 12:15

    Maybe you cloud use the Result property of Task. It works on .NET 4.0/4.5 and Windows Phone 8.

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