Question

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

Was it helpful?

Solution

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

OTHER TIPS

See this CodeProject article: A Pretty Good Splash Screen in C#

It implements a splash screen that:

  • Runs on a separate thread
  • Fades in as it appears, and fade out as it disappears
  • Displays a running status message that is updated using a static method
  • Displays and update a predictive self-calibrating owner-drawn smooth-gradient progress bar
  • Displays the number of seconds remaining before load is complete

Here's an example of what it looks like - maybe yours will be prettier. 8-)

alt text

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top