4
votes

I want to show a splash screen while my application's main form is loading and the splash form should disappear without me having to build in timers etc. Another important thing is that the main form should be the one determining when the application exits, when I use my splash form to start the application and then use it to open my main form I cannot dispose the splash screen, since that will kill the application.

1
create a kill thread and use sleep. But you may as well use timers. No need to fear them.David Heffernan

1 Answers

9
votes
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);
    }
}