views:

287

answers:

2

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

+2  A: 

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!

Neil
+5  A: 

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.

AnthonyWJones