I am not really sure about what is the best way to deal with operations executed in background threads in an application I am writing.
I am writing it in C# and I am following the MVVM design pattern. Some user actions are expensive and I'd like to run them in a background thread, which is a quite straightforward approach.
The worker thread then modifies my model, which notifies the ViewModel that something changed and finally the change gets propagated to the View.
My problem is that the chain of events triggered would cause the modification of the View from the background thread, when it is only allowed in the UI thread.
I know I can use the UI thread dispatcher but I am not really sure where (could the view-model be the right place?) so I'd like to know if you follow any design pattern to address this situation.