In my application I realized a custom statusbar control. It has progressbar, statusTextBox etc. Other modules could get the instance of that class with MEF, and bind their data in his elements with methods and properties. The problem is that the View of my statusbar updates only after some operation has finished.
Here is a code example:
[ImportingConstructor]
public IconManagerModel(IStatusBar statusBar)
{
StatusBar = statusBar;
}
public void SomeMethod()
{
for(...)
{
//I tried to use Dispatcher but it didn't help. View updates after method has finished
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal,
delegate()
{
StatusBar.SetProgress(amountComleted,total)
}
);
// ...
}
}
Thanx
You want to run
SomeMethod()on another thread, then call back onto theDispatcherto update the progress. Really, if the custom progress bar is hooked up to some UI element, then the implementation should handle the calling back onto the UI thread.You may want something a little like:
SomeMethod()will now be running on a different thread, so if you update the progress on the UI thread then you should see the results you desire.