I have tried to find out the answer but no real answer found. Can anyone answer following? I am trying to update status in the parent window by calling Dispatcher Method, but I see it does not update the status in sequential manner. I see the status update in the mainwindow as follow:
First process started... First Process done! Third Process done!
Instead of delay between the UpdateStatus, there can be some other method or task. So, Why it does not update other status? Any real answer please?
private void Button_Click(object sender, RoutedEventArgs e)
{
UpdateStatus("First Process started...");
Thread.Sleep(5000); //or any method
UpdateStatus("First Process done!");
Thread.Sleep(5000); //or any method
UpdateStatus("Second Process started...");
Thread.Sleep(5000); //or any method
UpdateStatus("Second Process done!");
Thread.Sleep(5000); //or any method
UpdateStatus("Third Process started...");
Thread.Sleep(5000); //or any method
UpdateStatus("Third Process done!");
}
private void UpdateStatus(string message)
{
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
{
MainWindow.main.lblTest.Content = message;
}
));
}