我有一个带有计时器的对象,当计时器达到 5 分钟时它会引发一个事件。在这种情况下,我在 MainWindow.xaml.cs 中调用 MessageBox.Show("Something")。
问题是当我调用 MessageBox.Show() 时,计时器停止,直到用户点击确定。即使用户没有点击确定,我也需要计时器继续运行。哪里有一个好的,优雅的方式来做到这一点?这是我迄今为止尝试过的(但没有奏效):
private void OnAlert(object sender, MvpEventArgs e)
{
this.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
MessageBox.Show("Alert");
}
));
}