MessageBox / ShowDialog()如何阻止程序继续运行?

时间:2019-02-14 17:14:36

标签: c# wpf

当您显示MessageBox或其他类型的对话框(例如OpenFileDialog或什至是用ShowDialog()调用的窗口)时,该方法内部发生了什么,以防止应用继续运行等待DialogResult被设置吗?

public static bool MyDialog.Show(string message) {
   //what happens here to keep the program from continuing?

   //Oh! DialogResult was finally set...
   return DialogResult;
}


private void OkButton_Click(object sender, RoutedEventArgs e) {
    DialogResult = true
}

这不像您可以放一会儿(true)循环并等待用户点击确定,那么后台实际上发生了什么?

0 个答案:

没有答案