Stream Protection, Silverlight

I use RIA WCF Services very often, and I insert the same context into multiple ViewModel. My problem is that, as you know, the context of RIA services is not thread safe.

So, my home solution for synchronization. I use background workers, and using PostSharp, I apply my [UniqueThread ("Data")] attribute according to the method and voila.

Am I complicating things? Are there simpler solutions?

Regards,
Vincent BOUZON

+1
source share
2 answers

OnUiThread BaseViewModel ( INotifypropertyChanged ).

, , , OnUiThread ( ) .

protected delegate void OnUiThreadDelegate();

protected void OnUiThread(OnUiThreadDelegate onUiThreadDelegate)
{
    if (Deployment.Current.Dispatcher.CheckAccess())
    {
        onUiThreadDelegate();
    }
    else
    {
        Deployment.Current.Dispatcher.BeginInvoke(onUiThreadDelegate);
    }
}

:

this.OnUiThread(() =>
    {
        this.ViewModelList = resultList;
    });
+4

, , , , . , , , , , , . () ?

0

All Articles