SPLASH Screen problems

it loads twice for no reason

Page 1 of 1

3 Replies - 1895 Views - Last Post: 04 March 2009 - 08:51 AM Rate Topic: -----

#1 twist2b  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-March 09

SPLASH Screen problems

Posted 01 March 2009 - 12:17 PM

Hi, I am having the dumbest problem, and I am sure there is a simple fix....
I am just trying to create a simple splash screen while the app is loading :P

Here is my code:

In Form load I have other stuff but the part that is important in my question:
			SplashScreen screen = new SplashScreen();
			if (screen.Opacity != 0)
			{
				if (backgroundWorker4.IsBusy != true)
				{
					backgroundWorker4.RunWorkerAsync();
				}
			}


Then the background LOADS the splash form:
		private void backgroundWorker4_DoWork(object sender, DoWorkEventArgs e)
		{
			SplashScreen screen = new SplashScreen();
			screen.Show();
			Thread.Sleep(3000);
			screen.HideForm();
			screen.Opacity = 0;
		}



Screen.Show obviously displays the form... once its displayed I hold that for 3 seconds and then the HideForm:
[code]
this.Opacity = 0;
this.Close();
[code]
I did the opacity twice just to see if the problem lies in disposing the form once its hidden.
I have many different forms that load, so if you open another form by clicking on something, then go back to form 1 it will load the splash again.... VERY painful. But it loads it only one more time. If I load another form AGAIN and then load THIS form, it does not show up.
So why is it working the SECOND time, but not the first?

Is This A Good Question/Topic? 0
  • +

Replies To: SPLASH Screen problems

#2 djkitt  Icon User is offline

  • D.I.C Head

Reputation: 29
  • View blog
  • Posts: 189
  • Joined: 22-May 08

Re: SPLASH Screen problems

Posted 03 March 2009 - 12:05 AM

So, it looks to me like you are testing the opacity of one instance of splashScreen and setting the opacity of a different instance.


Hope this helps,

Kitt

This post has been edited by PsychoCoder: 03 March 2009 - 12:18 AM

Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: SPLASH Screen problems

Posted 03 March 2009 - 12:17 AM

You're creating two instances of your splash screen, so of course it's going to show twice.
Was This Post Helpful? 0
  • +
  • -

#4 [email protected]  Icon User is offline

  • 僕は馬鹿ですね?
  • member icon

Reputation: 36
  • View blog
  • Posts: 1,018
  • Joined: 20-February 09

Re: SPLASH Screen problems

Posted 04 March 2009 - 08:51 AM

PsychoCoder is right if you get rid of one of the
SplashScreen screen = new SplashScreen();

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1