WPF -- Event Threading, GUI updating question
- by LSTayon
I'm trying to send two events to the main window so that I can show some kind of animation that will let the user know that I'm updating the data.
This is an ObservableCollection object so the OnPropertyChanged is immediately picked up by the bindings on the main window. The sleep is only in there so that the user can see the animation.
However, the first OnPropetyChanged is never seen. I'm assuming this is because we're in a single thread here and the timer_Tick has to finish before the GUI updates. Any suggetions? In VB6 land we would use a DoEvents or a Form.Refresh.
Thanks!
private void timer_Tick(object sender, EventArgs e)
{
Loading = "Before: " + DateTime.Now.ToString();
OnPropertyChanged("Loading");
LoadData();
Thread.Sleep(1000);
//Loading = Visibility.Hidden;
Loading = "After: " + DateTime.Now.ToString();
OnPropertyChanged("Loading");
}