Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight DataBinding cross thread issue

I have an Image control with it's source bound to a property on an object(string url to an image). After making a service call, i update the data object with a new URL. The exception is thrown after it leaves my code, after invoking the PropertyChanged event.

The data structure and the service logic are all done in a core dll that has no knowledge of the UI. How do I sync up with the UI thread when i cant access a Dispatcher?

PS: Accessing Application.Current.RootVisual in order to get at a Dispatcher is not a solution because the root visual is on a different thread(causing the exact exception i need to prevent).

PPS: This only is a problem with the image control, binding to any other ui element, the cross thread issue is handled for you.

like image 642
Brian Leahy Avatar asked Sep 05 '08 22:09

Brian Leahy


2 Answers

System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => {...});

Also look here.

like image 140
Phil Avatar answered Sep 29 '22 18:09

Phil


Have you tried implementing INotifyPropertyChanged?

like image 24
Jonathan Parker Avatar answered Sep 29 '22 16:09

Jonathan Parker