MessageBox.Show在调试时在异步方法内部时不显示

时间:2014-02-20 20:58:32

标签: silverlight

在调试应用程序时,我遇到了一些奇怪的行为,而MessageBox.Show没有显示。要重现,请使用以下命令并运行它。

它将按预期工作,显示消息框。

现在在DoSomething中放置一个断点并运行。 MessageBoxes将不会显示!

现在删除async关键字,它会再次按预期工作。

这是怎么回事?我有一个应用程序执行通常的确认对话框,但在调试过程中它们被跳过。我最终将它追溯到async关键字,但这对我来说没有任何意义。可能是调试器中的错误。

private void ButtonBase_OnClick(object sender, RoutedEventArgs e) {
       DoSomething();
    }

    public async void DoSomething() {
        MessageBox.Show("Starting");
        ShowMessageBox();
        MessageBox.Show("In DoSomething()");


    }

    public void ShowMessageBox() {
        MessageBox.Show("In ShowMessageBox");
    }

1 个答案:

答案 0 :(得分:0)

这似乎是Visual Studio的一个问题。

相关问题