Await blocks the UI Thread, Network Related

岁酱吖の 提交于 2019-12-04 14:05:25

Try calling RetrieveFeed() on a background thread. Perhaps processing the request or response is what takes a lot of time and if it is started on UI thread - it will run on UI thread.

Task<bool> success = null;
await Task.Run(
    () => success = newRssFeed.RetrieveFeed());

The use of the async/await look okay. You reference a distant Wi-Fi connection, this may be purely down to a weak signal, hence poor bandwidth.

I hope this helps.

I've the same issue on some of my Windows Phone apps and I don't have any good explanation, the only good one is the same that Killercam referred.

When you call an async method it doesn't return immediately (I assume that the methods aren't something like return Task.Factory.StartNew(...);), it does some work, sets the callback and then returns, if the work that it makes has anything related to network connections, in a slow connection this can block the function.

A good way to test this symptoms is connect to a router with wifi and then disconnect the router from the internet, you will have the same behavior that you are describing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!