static method \ object

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

Guest

Hi folks,

I am building a simple app which uses a splash Screen. As there will only be
one instance of the Splash Screen ever running at one time I am thinking that
it makes sense to make the Splash Screen a 'static object'. The Splash Screen
is a Windows form. Does this sound like the sensible thing to do?

Thanks for any opinions,
David
 
Hi folks,

I am building a simple app which uses a splash Screen. As there will only be
one instance of the Splash Screen ever running at one time I am thinking that
it makes sense to make the Splash Screen a 'static object'. The Splash Screen
is a Windows form. Does this sound like the sensible thing to do?

Yes. Actually, a clean way to deal with Splash screen is to add 2 static
methods to your SplashScreen class: ShowSplash() which creates a
SplashScreen object, stores it as a static variable and show it and
CloseSplash() which closes and disposes the SplashScreen object.
 
Splash screens are some kind of show and dispose windows (Objects). So it
does not make sense to set them static.
 
Mehdi said:
Yes. Actually, a clean way to deal with Splash screen is to add 2 static
methods to your SplashScreen class: ShowSplash() which creates a
SplashScreen object, stores it as a static variable and show it and
CloseSplash() which closes and disposes the SplashScreen object.

Sounds good, that is pretty much how I have done it. The actual Splash form
is a public static object and I have a static public method StartSplash()
which displays the Splash form and a CloseSplash() method which disposes of
the form. Seems to be working ok so far...

Best regards,
David
 
Hi,

David++ said:
Hi folks,

I am building a simple app which uses a splash Screen. As there will only
be
one instance of the Splash Screen ever running at one time I am thinking
that
it makes sense to make the Splash Screen a 'static object'.

No point, it will be shown only once if you do it static it will last for
the entire execution time.
Beside you cannot do it. your splash will be a type derived from Form hence
you cannot declare it as static (static cannot have a parent type , except
Object of course)

This is a question that pops quite frequentely , look into the archives for
solutions ( I did post once the code I use)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top