I have wpf application with button on it.
The click event of the button start process take for approximately 30-50 sec. I want to use progress bar while this thread is working. out of this i try also dispatcher.invoke. no success.
this is my code:
MainWindow.xaml.cs:
public MainWindow()
{
some code.....
Engine.ProgressEvent += (percent) => Dispatcher.Invoke(new Action(() => progressBarIndicator.Value = percent));
some code...
}
private void btnFirmwareUpdate_Click(object sender, RoutedEventArgs e)
{
some code...
send data to hardware using functions in Engine class
Engine e = new Engine();
e.update();
}
my Engine.cs :
Class Engine
{
public static event Action<double> ProgressEvent;
public update()
{
ProgressEvent(10);
}
}
the progress bar indeed get the update the progress bar in the correct value but the gui is not refreshing. solutions any one?