当您显示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)循环并等待用户点击确定,那么后台实际上发生了什么?