开发者

Silverlight and callbacks in non-UI threads

开发者 https://www.devze.com 2022-12-11 19:29 出处:网络
Does Silverlight ever callback in the non-UI thread after an Async task (such as event listening or network request)?

Does Silverlight ever callback in the non-UI thread after an Async task (such as event listening or network request)?

Assume that I've created no threads of my own.

Thanks, Ru开发者_Python百科i


Yes an Async task will often (if not even always) callback on a different thread than the UI thread. Hence the existence of the Dispatcher property on everything that has a UI (and even that don't). Its up to you to ensure that code that needs to run on the UI is invoked on the UI thread.

Unfortunately there is very little documentation on what can and can't be modified from a non-UI thread most probably because that could change from one version to the next.


If you follow the MVVM pattern, and you make a WCF async call in your viewmodel (cos all calls are aync in Silverlight), the callback will fire off even if you leave your current page in a navigation application, this can be annoying if your callback redirects to another page on success!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号