I have a popup in my application for showing messages. Sometimes, two messages get shown too quickly after one another and the second just overrides the first one, making it disappear too quickly.
So what I want is for the next message to wait for the previous message to close.
I'm using both a DispatcherTimer
and a MouseEvent to close the popup:
popupTimer.Interval = TimeSpan.FromSeconds(5d);
popupTimer.Tick += (sender, args) =>
{
popupMessage.IsOpen = false;
popupTimer.Stop();
};
popupMessage.MouseDown += (sender, args) =>
{
popupMessage.IsOpen = false;
popupTimer.Stop();
};
Showing the message is done like so:
popupMessage.Dispatcher.Invoke(
() =>
{
popupMessage.IsOpen = true;
popupTimer.Start();
});
Now if I place the following loop inside the show delegate
while(popupMessage.IsOpen) {}
The application just hangs inside it without IsOpen ever changing back to False, even after waiting 5 seconds for the timer to run out. Besides this, I don't like using a blocking while-loop like this.
Is there any way to make my messages wait on each other? I tried using a simple bool instead of PopupMessage's IsOpen, but to no avail.