System.Windows.MessageBox doesn't wait for user input before going poof!

后端 未结 7 1607
轻奢々
轻奢々 2021-01-08 00:56

...and it makes no sense why. T-T

In my Application_Startup event handler I have code that looks kinda like this:

private void Applicati         


        
7条回答
  •  一个人的身影
    2021-01-08 01:35

    Alexey is right, the splash screen closes the message box.

    A simple way to avoid this is to use the native MessageBox function:

    [DllImport("user32.dll", CharSet = CharSet.Unicode)]
    public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type);
    
    public static void Main()
    {
       ...
       MessageBox(new IntPtr(0), "Hello World!", "MyApp", 0);
    

提交回复
热议问题