views:

629

answers:

5

When starting my app I at first have to read in some data, have to init some forms and so on. For that time the user sees just grey getting-ready to show something forms.

This lasts for a few seconds...

I thought of a Splash Screen that loads the data in a seperate Thread and also shows how long it will take. Or just a status bar?

How would you do something like this?

I'm using C# .NET 3.5 + Winforms

+7  A: 
RichieHindle
I had a look at that one before but it's not that good - he uses DoEvents() instead of a real thread and he does some not thread-save actions that are no longer allowed in .NET 3.5
Kai
@Kai: Are you sure? I see this: `ms_oThread = new Thread( new ThreadStart(SplashScreen.ShowForm));` which certainly looks like a real thread to me. And no mention of `DoEvents`.
RichieHindle
@Kai: Im evaluating the same article Richie has pointed out. Scroll down to view one of the comments by Mahin Gupta who has recently re-written some of the code for .net3.5 compatibility, including some thread-safe issues.
Shalan
http://blog.mahingupta.com/mahingupta/blog/post/2009/07/26/Winforms-splash-screen-Great-work-by-Tom.aspx
Shalan
+1  A: 

Hi,

With WindowsForm, the easier is to use Backgroundworker.

You can disables controls during loading and display a progress bar on startus bar with label as "loading data...".

MSDN link : http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

Xstahef
A: 

How would you create a splashscreen if you for instance had to wait on Windsor or NHibernate? Could you create a splashscreen for this?

Sven
@Sven: That's why you put it in its own thread, which you start as soon as your app starts.
RichieHindle
A: 

If it only lasts a few seconds then displaying the wait cursor should be fine. Perhaps it can be arranged that the main window is shown as quickly as possible and the rest is started after the first screen update (e.g. using a timer). This will reduce the perceived start-up time.

In order to reduce the startup time you may also consider postponing some of startup actions if they are not strictly necessary. It can be done later in the background using a timer or on-demand.

Peter Mortensen
A: 

I recently wrote a similar splash screen using Tom Clements as a basis. Take a look at My Splash Screen to see if it fits your needs.

John Hunter