Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Splash Screen Architecture

Splash Screen Architecture

Scheduled Pinned Locked Moved C#
csharparchitecturetutorialquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 1 Offline
    1 Offline
    1nsp1r3d
    wrote on last edited by
    #1

    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.

    C C 2 Replies Last reply
    0
    • 1 1nsp1r3d

      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.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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++

      1 1 Reply Last reply
      0
      • C Christian Graus

        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++

        1 Offline
        1 Offline
        1nsp1r3d
        wrote on last edited by
        #3

        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.

        C 1 Reply Last reply
        0
        • 1 1nsp1r3d

          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.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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++

          S 1 Reply Last reply
          0
          • C Christian Graus

            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++

            S Offline
            S Offline
            S Senthil Kumar
            wrote on last edited by
            #5

            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

            C 1 Reply Last reply
            0
            • S S Senthil Kumar

              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

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              How does a splash screen 'freeze' ? I guess if you move something in front of it ? Christian Graus - Microsoft MVP - C++

              S 1 Reply Last reply
              0
              • 1 1nsp1r3d

                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.

                C Offline
                C Offline
                cmaissan
                wrote on last edited by
                #7

                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

                1 1 Reply Last reply
                0
                • C Christian Graus

                  How does a splash screen 'freeze' ? I guess if you move something in front of it ? Christian Graus - Microsoft MVP - C++

                  S Offline
                  S Offline
                  S Senthil Kumar
                  wrote on last edited by
                  #8

                  Yes. And if you intend to show some dynamic text in the splash screen window. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                  1 Reply Last reply
                  0
                  • C cmaissan

                    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

                    1 Offline
                    1 Offline
                    1nsp1r3d
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups