Tuesday, 17 August 2010

Silverlight Deployment dispatcher

Note to self. I encountered this problem when trying to access WCF Data Services from a Silverlight App, specifically when running out of browser. Trying to set a collection that's bound to a UI thread throws a cross thread exception, you're supposed to use the UI Thread dispatcher.

A lot of examples suggest you use the Application layout root dispatcher, but Shawn Wildermuth (as is so often the case, thanks Shawn!) has the right answer. You need to use the Dispatcher in the Deployment class as such.

        () => results.Text = "Pooled Dispatcher Worked");

Works like a charm.

No comments: