我是在WPF程序测试中发现的这个问题,当我频繁的点击一个按钮,就会出现这样的情况。
App.Current.Dispatcher.Invoke((Action)(() =>
{
Result = MessageBoxX.Show(argMsg, argTitle, null, argButtons, new MessageBoxXConfigurations()
{
MessageBoxStyle = MessageBoxStyle.Modern,
MessageBoxIcon = argIcon,
ReverseButtonSequence = true,
ShowInTaskbar = false,
ThemeBrush = (System.Windows.Media.SolidColorBrush)Application.Current.FindResource("HeadColorBrush")
});
}));
然后我再出错误的地方加上了这个东西,就不报错了。但是界面会卡死。然后就只好使用了这样一个方式。加上try catch。
try
{
Result = MessageBoxX.Show(argMsg, argTitle, null, argButtons, new MessageBoxXConfigurations()
{
MessageBoxStyle = MessageBoxStyle.Modern,
MessageBoxIcon = argIcon,
ReverseButtonSequence = true,
ShowInTaskbar = false,
ThemeBrush = (System.Windows.Media.SolidColorBrush)Application.Current.FindResource("HeadColorBrush")
});
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
把
App.Current.Dispatcher.Invoke换成try catch,索然会报错,但是不会显示出来。***我为什么要这么做呢!因为我的按钮事件中都没有用到这一块的代码***所以只好屏蔽掉了