Splash Screen Architecture
-
Hello all, After reading almost all tutorials on splash screen for C# I'm quite confused which aproach to take. So I want to ask you what would be the best way. Personally, what I've been thinking is doing something like this: 1. In Main() start the splash thread 2. Run the Main form thread 3. main form thread sends signals to the splash thread about the progress 4. main form sends a signal to the splash thread that it has finished and the splash thread closes itself The thing is that I've done some threading recently but I haven't actually encountered how to call object methods on different threads. Another thing which I'm not sure about is, should the function which is to be called for the start point of the thread call Application.Run(SplashThread) for the splash thread and Application.Run(MainForm) ? Any advice is greatly appreciated.
-
Hello all, After reading almost all tutorials on splash screen for C# I'm quite confused which aproach to take. So I want to ask you what would be the best way. Personally, what I've been thinking is doing something like this: 1. In Main() start the splash thread 2. Run the Main form thread 3. main form thread sends signals to the splash thread about the progress 4. main form sends a signal to the splash thread that it has finished and the splash thread closes itself The thing is that I've done some threading recently but I haven't actually encountered how to call object methods on different threads. Another thing which I'm not sure about is, should the function which is to be called for the start point of the thread call Application.Run(SplashThread) for the splash thread and Application.Run(MainForm) ? Any advice is greatly appreciated.
I don't see the need for another thread. Your main thread can just open a window which shows the splash screen, then close it using either a timer, or at a specific point during initialisation ( i.e. just before the main app is ready to show itself ). Christian Graus - Microsoft MVP - C++
-
I don't see the need for another thread. Your main thread can just open a window which shows the splash screen, then close it using either a timer, or at a specific point during initialisation ( i.e. just before the main app is ready to show itself ). Christian Graus - Microsoft MVP - C++
-
But if I show the splash using Application.Run(Splash); the function will return when the splash is closed, am I right? If it's that way, then I'm in a deadlock. That's why I resort the threads.
1nsp1r3d wrote: Application.Run(Splash); Why would you do this ? I'm talking about a modeless form being shown by your application, during startup. Sure, you can use a thread, it just seems like overkill to me. Christian Graus - Microsoft MVP - C++
-
1nsp1r3d wrote: Application.Run(Splash); Why would you do this ? I'm talking about a modeless form being shown by your application, during startup. Sure, you can use a thread, it just seems like overkill to me. Christian Graus - Microsoft MVP - C++
Because using the same message pump for both the splash screen and the main application window might cause the splash screen to freeze if there is some heavy duty initialization involved. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Because using the same message pump for both the splash screen and the main application window might cause the splash screen to freeze if there is some heavy duty initialization involved. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
How does a splash screen 'freeze' ? I guess if you move something in front of it ? Christian Graus - Microsoft MVP - C++
-
Hello all, After reading almost all tutorials on splash screen for C# I'm quite confused which aproach to take. So I want to ask you what would be the best way. Personally, what I've been thinking is doing something like this: 1. In Main() start the splash thread 2. Run the Main form thread 3. main form thread sends signals to the splash thread about the progress 4. main form sends a signal to the splash thread that it has finished and the splash thread closes itself The thing is that I've done some threading recently but I haven't actually encountered how to call object methods on different threads. Another thing which I'm not sure about is, should the function which is to be called for the start point of the thread call Application.Run(SplashThread) for the splash thread and Application.Run(MainForm) ? Any advice is greatly appreciated.
You could do all your initializing in the Main() function. Something like as follows: static void Main() { // Create splash fclsSpash splash = new fclsSplash(); splash.Show(); // Create main form fclsMain main = new fclsMain(); // Initialize this splash.SetMessage("Initializing this."); main.InitializeThis(); // Initialize that splash.SetMessage("Initializing that."); main.InitializeThat(); // Close splash splash.Dispose(); // Show main main.Show(); // Start application Application.Run(); } -Chris
-
How does a splash screen 'freeze' ? I guess if you move something in front of it ? Christian Graus - Microsoft MVP - C++
Yes. And if you intend to show some dynamic text in the splash screen window. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
You could do all your initializing in the Main() function. Something like as follows: static void Main() { // Create splash fclsSpash splash = new fclsSplash(); splash.Show(); // Create main form fclsMain main = new fclsMain(); // Initialize this splash.SetMessage("Initializing this."); main.InitializeThis(); // Initialize that splash.SetMessage("Initializing that."); main.InitializeThat(); // Close splash splash.Dispose(); // Show main main.Show(); // Start application Application.Run(); } -Chris
Hello, I did solve my problem with the initial structure. So this is what I'm doing in Main(): 1. Create Splash thread 2. Start Splash thread 3. Create Main Window Thread 4. Start Main Window Thread 5. Hide Main Window The thing which I'm working now is to implement an event which will signalize the splash screen that main is ready and it should close itself and Main form should appear.