sluggish splash screen

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I implemented the simplest of splash screens ( static and on its own thread ). But it seem that when first called maybe 8 seconds elapsed before it showed up, the main form follows several seconds later.

Naturally recalling the application, the response is adequate

I have 10 classes in my project. Some small, none really huge. And another form

public class frmQCLoader : System.Windows.Forms.For
{
private System.Windows.Forms.DataGrid QCDG
private System.Windows.Forms.Button btnLoad
private System.Windows.Forms.Button btnInstall
... 2 of my classe
more native control

public frmQCLoader(

// Required for Windows Form Designer suppor
frmStatic.ShowStaticForm(); // SO ITS FIRST in the STAC

Is is likely the considerable delay is called by instantiating my classes for referencing throughout the for
and if so, is there a way to around this ? Thank
 
Hi Andrew,

If you look in the archives you will see some simples ways of doing a splash
screen, below you will find the code I'm using and it works fine.
You can say that the trick is show the form in the Main() method. this
assure that the splash is shown as early as possible

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


//************* The main form START CODE *************////////

public Form1()
{
InitializeComponent();
//This is the reason of the splash screen, to load data in the back :)
DataProvider.LoadData();
splashform.CloseIt();
}
[STAThread]
static void Main()
{
splashform = new splash();
Application.Run(new Form1());
}
//************* The main form END CODE *************////////

Below is the code for the splash window, only the code important to it is
shown, the rest is the regular code found in a windows form

//************* The splash form START CODE *************////////
DateTime time;
public splash()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

// Show the splash screen
Show();
//To know how many time it has been displayed
time = DateTime.Now;

Application.DoEvents();
}

public void CloseIt()
{
TimeSpan T = DateTime.Now - time;
// if the method was closed before a specific amount of time, wait for the
different and later close the form.
if (T.Milliseconds<3000)
System.Threading.Thread.Sleep(3000-T.Milliseconds);
this.Close();
}
//************* The splash form END CODE *************////////

andrewcw said:
I implemented the simplest of splash screens ( static and on its own
thread ). But it seem that when first called maybe 8 seconds elapsed before
it showed up, the main form follows several seconds later.
Naturally recalling the application, the response is adequate.

I have 10 classes in my project. Some small, none really huge. And another form.

public class frmQCLoader : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid QCDG;
private System.Windows.Forms.Button btnLoad;
private System.Windows.Forms.Button btnInstall;
... 2 of my classes
more native controls

public frmQCLoader()
{
// Required for Windows Form Designer support
frmStatic.ShowStaticForm(); // SO ITS FIRST in the STACK

Is is likely the considerable delay is called by instantiating my classes
for referencing throughout the form
 
The problem is more than likely due to the fact that your app is loading and
initializing multiple modules. All that adds up to a slow splash screen.

Have you looked into delayed/demand loading of your modules? (i.e. loading the
module when first accessed). Look in MSDN documentation for details on how to
do this.

If that doesn't work, you may have to simply create a stub app that simply
displays your splash screen and then executes your actual app? I've done this
in previous projects -- a little cumbersome, but it provides *instantaneous*
response to the user.
 
Hi Andrew,

Does the community's reply make sense to you?

If you still have anything unclear, please feel free to post, I will help
you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top