Over a million developers have joined DZone.

Windows Phone Pitfall: Deployment.Current.Dispatcher

· Mobile Zone
You Windows Phone Developers will be interested to find out about a major pitfall (it might be considered a bug eventually) when you are building a component or application that needs to dispatch messages back to the UI thread.  Here were some of his potential solutions/workarounds to this side effect:









We don't have public access to information about the queued messages in the dispatcher, and of course there's also no way to manually manipulate them. So obviously there are two possible attempts: a) prevent posting to the UI thread once the application gets deactivated, or b) ignore undesired messages posted to the UI thread after activation. Both have a hacky smell to them, but the first one seems more promising. However, I've not yet thought about how this could be handled consistently or if it is possible at all; if I manage to come up with some clean solution, I will do a follow-up post about it.

You can get a full description of this potential pitfall and see example code by following the source link below:

Source: http://www.pitorque.de/MisterGoodcat/post/Windows-Phone-7-Pitfall-The-Dispatcher-and-Deactivation.aspx
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}