如何在不设置定时器等的情况下在Windows窗体应用程序中构建启动画面?

Vel*_*uis 4 .net c# splash-screen winforms

我希望在我的应用程序的主窗体加载时显示启动画面,并且启动窗体应该消失,而不必在构建定时器等等.另一个重要的事情是主窗体应该是确定何时应用程序退出,何时使用我的启动窗体启动应用程序然后用它来打开我的主窗体我无法处理启动画面,因为这会杀死应用程序.

Vel*_*uis 7

using Microsoft.VisualBasic.ApplicationServices;

public class Startup : WindowsFormsApplicationBase
{
    protected override void OnCreateSplashScreen()
    {
        SplashScreen = new SplashForm();
    }

    protected override void OnCreateMainForm()
    {
        MainForm = new MyMainForm();
    }
}

static class Program
{
    static void Main(string[] args)
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        new Startup().Run(args);
    }
}
Run Code Online (Sandbox Code Playgroud)