Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight and callbacks in non-UI threads

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, Rui

like image 617
rui Avatar asked Feb 28 '23 01:02

rui


2 Answers

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.

like image 119
AnthonyWJones Avatar answered Mar 08 '23 16:03

AnthonyWJones


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!

like image 26
Neil Avatar answered Mar 08 '23 15:03

Neil