I have essentially the same problem discussed here: http://khason.net/blog/dependency-property-getters-and-setters-in-multithreaded-environment/
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.RegisterAttached("MyProperty", typeof(bool),
typeof(MyObject), new PropertyMetadata(new PropertyChangedCallback(OnMyPropertyChanged)));
public static bool GetMyProperty(DependencyObject obj)
{
return (bool)obj.GetValue(MyPropertyProperty); <<<<<
}
public static void SetMyProperty(DependencyObject obj, bool value)
{
obj.SetValue(MyPropertyProperty, value);
}
If the line marked "<<<<<" gets called from a background thread, Silverlight throws an InvalidOperationException and my app will probably deadlock.
Unfortunately the solution from the blog post won't work because the Silverlight version of the Dispatcher class hides the synchronized Invoke methods -- only BeginInvoke is marked public.