.net Windows窗体启动屏幕没有';t显示

.net Windows窗体启动屏幕没有';t显示,.net,vb.net,winforms,splash-screen,.net,Vb.net,Winforms,Splash Screen,我有一个Windows窗体项目,用vb.NET2005编写 除了在显示frmMain之前不会显示启动屏幕外,所有操作都正常 在项目属性中,我设置了启动屏幕。 在显示的启动屏幕事件中,我使用System.Threading.Thread.Sleep(3000) 但是主MDI表单刚刚加载,然后启动屏幕明显在它后面,因为光标显示“Wait”几秒钟 在VS2005中,它曾经工作得很好,先显示启动屏幕几秒钟,然后加载主窗体 在VS 2008中我还需要做些什么吗 感谢单击项目-->属性-->应用程序选项卡-

我有一个Windows窗体项目,用vb.NET2005编写

除了在显示frmMain之前不会显示启动屏幕外,所有操作都正常

在项目属性中,我设置了启动屏幕。 在显示的启动屏幕事件中,我使用
System.Threading.Thread.Sleep(3000)

但是主MDI表单刚刚加载,然后启动屏幕明显在它后面,因为光标显示“Wait”几秒钟

在VS2005中,它曾经工作得很好,先显示启动屏幕几秒钟,然后加载主窗体

在VS 2008中我还需要做些什么吗

感谢

单击项目-->属性-->应用程序选项卡-->(向下滚动至右下角-->“查看应用程序事件”按钮,您应该会看到如下内容:

Namespace My

    ' The following events are available for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

    End Class

End Namespace
现在覆盖OnInitialize()并设置MinimumSplashScreenDisplayTime(),如下所示:


在显示UI的线程上使用Thread.Sleep()是一种很好的方法,可以引起这样的随机问题。当窗口停止响应消息时,Windows会非常生气。改为增加MinimumSplashScreenDisplayTime属性值。@HansPassant,谢谢-请问设置在哪里?我在Project或frmSplash属性中看不到它。看这里,我已经这样做了,在主MDI屏幕显示之前,启动屏幕只显示不到一秒钟。如果我立即关闭主窗口,在应用程序退出之前,我可以看到启动屏幕。这真的很奇怪,如果我从\bin\debug文件夹运行exe,启动屏幕会显示3秒钟,主窗体在它后面,而如果我在VS 2008 IDE中用F5运行它,我会在我之前的评论中看到问题的轮廓!
Namespace My

    ' The following events are available for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

        Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
            ' Set the display time to 3000 milliseconds (3 seconds):
            Me.MinimumSplashScreenDisplayTime = 3000
            Return MyBase.OnInitialize(commandLineArgs)
        End Function

    End Class

End Namespace