I used the solution suggested by Fredrick Merck. It is very clear and elegant. Otherwise, I found the problem if we create a splash form before running the real application (application.run (mainform ...)):
it throws an invalidOprationException, caused by the fact that the descriptor form does not yet exist in the calling thread. To create a descriptor directly in thread t (and skip this exception!), Try running the splash form as follows:
Thread t = new Thread(new ThreadStart(delegate { _splash = new Splash(); Application.Run(_splash); })); t.Start();
and if you plan to call the closeSplash method in more branches of the program, force a null value after the first call:
private static Splash _splash = null; public static void CloseSplash() { if (_splash!= null) { _splash.CloseSplash(); _splash=null; } }
ghillo
source share