MessageBox在SaveFileDialog之后没有显示(聚焦)

Rob*_*ock 7 c# visual-studio-2010 winforms

出于某些原因,在我的SaveFileDialog之后,我的应用程序将永远不会显示MessageBox.有什么我想念的吗?或者这是一个线程问题?

我使用VS 2010 Express将应用程序作为Windows窗体应用程序运行.

我没有任何例外.

添加:当我单步执行代码时,一切似乎都很顺利.这很奇怪,所以我认为这是一个时间问题.

LarsTech和其他人指出,MessageBoxes确实出现了,但重点已经消失; 换句话说,MessageBox被推到其他窗口后面或最小化.这是个问题.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.IO;
namespace SpeedDating
{
    class Program
    {
         [STAThread]
        static void Main(string[] args)
        {

        string filename = "test.test"; // args[0];
        string ext = filename.Substring(filename.LastIndexOf('.'));
        SaveFileDialog dialog = new SaveFileDialog();
        dialog.Title = "SpeedDating App";
        dialog.RestoreDirectory = true;
        dialog.CheckFileExists = false;
        dialog.CheckPathExists = false;
        dialog.FileName = DateTime.Now.ToString("yyyyMMdd") + ext;

        DialogResult result = dialog.ShowDialog();
        if (result == DialogResult.OK && dialog.FileName != "")
        {
            try
            {
                FileStream outfs = File.Create(dialog.FileName);
                FileStream infs = File.Open(filename, FileMode.Open);
                infs.CopyTo(outfs);
                infs.Close();
                outfs.Close();
            }
            catch (NotSupportedException ex)
            {
                MessageBox.Show("Probably removed the original file.");
            }
        }
        else
        {
            MessageBox.Show("No path found to write to.");
        }

        MessageBox.Show("I came here and all I got was this louzy printline");

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Edp*_*per 5

我尝试了这个,它立即显示:

 MessageBox.Show(new Form() { WindowState = FormWindowState.Maximized, TopMost = true }, "You clicked Cancel button", "Cancel");
Run Code Online (Sandbox Code Playgroud)