.NET 3.5 SP1 Splashscreen

Nov 3, 2008 at 9:51 PM
Hi All,

I've implemented a Splashscreen in my app using the new SplashScreen class in SP1.  However, when my app launches the splash screen ends up hidden behind the window whilst it initialises all the modules.  Once the sceen is ready to show the default modules view the splash screen reappears and then fades out.  Doesn't look cool at all ...

The splash screen class by default closes when the window first appears which explains why its hidden whilst the modules are enumerated.  The class can't tell that there is still a stack of work left to do.  Does anyone know of a possible solution to this in the context of CAL?

Cheers,
Nov 11, 2008 at 7:25 PM
Edited Nov 11, 2008 at 7:29 PM

Hi,

 

Based on your comments, I assume that you may be implementing the SplashScreen in one of these ways:

·         Setting the BuildAction property to SplashScreen on an Image of your project.

·         Using the SplashScreen class like the following:

SplashScreen ss = new SplashScreen("splashScreen.PNG");

ss.Show(true);

 

The problem with these implementations is that the Show method is called passing the parameter “true”, for this reason, the splash screen will be automatically close when the application finished to load, but with a delay of 300 miliseconds (this causes the fade out).

You can find more information about how the SplashScreen class works in the following links:

·         SplashScreen Class

·         SplashScreen.Show Method

 

A possible workaround to solve this, is calling the Show method passing the parameter “false” (In this way, you have to close the SplashScreen manually) and close the splash screen without delay when the application finishes loading.

Here you can find a possible implementation of this using the OnStartup method of your App class:

 

  protected override void OnStartup(StartupEventArgs e)

  {

            SplashScreen ss = new SplashScreen("splashScreen.PNG");

            ss.Show(false);

 

            base.OnStartup(e);

 

        #if (DEBUG)

            RunInDebugMode();

        #else

            RunInReleaseMode();

        #endif

 

            this.ShutdownMode = ShutdownMode.OnMainWindowClose;

           

            ss.Close(new TimeSpan ()); //Close the SplashScreen immediately

  }

 

Please, Let me know if you find this useful or if the problem persists, please provide more information into this matter.

 

Ezequiel Sculli

http://blogs.southworks.net/esculli/

Nov 12, 2008 at 8:46 PM
Hi Ezequiel,

Thanks for the reply.  The problerm I'm having is that the splashscreen class is only active prior to the main window opening.  It then performs the fade out.

However, in my app the loading time extends past the window opening whilst the applications modules are enumerated and the app initialises.  As soon as the main window opens it is on top of the splash screen.  In addition to this because the module enumeration is chugging away on the UI thread the actual fade out can't happen.  So when the windows contents is actually rendered and frees up the UI thread the splashscreen suddenly appears and immediately starts its fade out animation.

I have tried your code above and it certainly tidies things up in that the splashscreen no longer performs its fade.

It seems that in a situation with a longer loading time past the window appearing the splashscreen needs to close at the end of module enumeration rather than simply the window appearing, even though its still empty!

Thanks,