static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//-----------------------
SplashScreen = new StartLoadingScreen();
var splashThread = new Thread(new ThreadStart(() => Application.Run(SplashScreen)));
splashThread.SetApartmentState(ApartmentState.STA);
splashThread.Start();
MainForm = new frmLogin();
MainForm.Load += MainForm_LoadCompleted;
Thread.Sleep(2000);
Application.Run(MainForm);
}
private static void MainForm_LoadCompleted(object sender,EventArgs e)
{
if (SplashScreen != null && !SplashScreen.Disposing && !SplashScreen.IsDisposed)
SplashScreen.Invoke(new Action(() => SplashScreen.Close()));
MainForm.TopMost = true;
MainForm.Activate();
MainForm.TopMost = false;
}