【发布时间】:2021-03-16 19:05:03
【问题描述】:
您好,我正在为我的程序测试一些东西,每次测试完成时都会显示一个新的消息框。 问题是在我之前关闭消息框后只会打开一个新的消息框。 我尝试将消息框放入新任务中,但这也不起作用...
Task.Run(() => System.Windows.MessageBox.Show(
dirs[directory] + " is done, it took " + stopwatch.Elapsed,
"Done with " + dirs[directory],
System.Windows.MessageBoxButton.OK,
System.Windows.MessageBoxImage.Information,
System.Windows.MessageBoxResult.OK,
System.Windows.MessageBoxOptions.ServiceNotification));
我也尝试使方法异步并等待Task.Run,也没有运气
await Task.Run(() => System.Windows.MessageBox.Show(
dirs[directory] + " is done, it took " + stopwatch.Elapsed,
"Done with " + dirs[directory],
System.Windows.MessageBoxButton.OK,
System.Windows.MessageBoxImage.Information,
System.Windows.MessageBoxResult.OK,
System.Windows.MessageBoxOptions.ServiceNotification));
【问题讨论】:
标签: wpf async-await task messagebox