On a WPF form I need two status messages in a text field while the program does some lengthy task: "Started" and "Finished" to keep it simple. The message is shown in a textblock bound to a property with OnPropertyChange
in the setter of course.
Problem: Only the second message is shown when I change this property.
StatusMessage = "Started";
Thread.Sleep(700); // Searching the harddrives and make some lists in the real prog.
StatusMessage = "Finished";
Strange for me: If I place a MessageBox.Show
between first change of property and the Sleep
- which doesn't make sense of course - everything works fine:
StatusMessage "Started";
MessageBox.Show("Just click");
Thread.Sleep(700);
StatusMessage "Finished";
Trying to achieve the same with a message window shows nearly same behavior: The new window opens but isn't filled with content - unless a put a senseless MessageBox.Show
into the code. (I guess this has the same root cause so add this in the thread here.)
MsgWindow mw = new MsgWindow();
mw.Show();
MessageBox.Show("Just click"); //If I delete this line the window opens without content, color etc.
Thread.Sleep(700);
mw.Close();
Where is my mistake?