If the property ProgressBarValue
is bound to a WPF element, then the only thread that can update the ProgressBar
is the very thread that created it.
So, my assumption is that the class that contains ProgressBarValue
also implements INotifyPropertyChanged
. This means that you have some logic that raises the event PropertyChanged
.
I would create a method that raises the event, and always does so using the Dispatcher
. (The Dispatcher
allows you to call functions on the thread that created your WPF controls.)
private void raisePropertyChanged(string name)
{
Dispatcher.InvokeAsync(()=>
{
if(PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(name));
});
}
This will always update the ProgressBar
on the proper thread.