0

I've have made my program do what I want it to do, which is to make the screen flash white and slowly fade out. When I compile and run it in Visual Studio 2013, it works flawlessly, but when I run it from the bin folder where the .exe is located, the screen just stays white and doesn't do anything then crashes.

Here is my code:

public static void StartForm() {

  Form Form1 = new Form();
  Form1.FormBorderStyle = FormBorderStyle.None;
  Form1.Size = new Size(ScreenWidth, ScreenHeight);
  Form1.BackColor = Color.White;
  Form1.Show();

  for (int i = 100; i >= 0; i = i - 1) {
    Form1.Update();
    Form1.Opacity = Form1.Opacity - .01;
    System.Threading.Thread.Sleep(10);
  }
  System.Threading.Thread.Sleep(100);
  Form1.Hide();
}
leppie
  • 115,091
  • 17
  • 196
  • 297
madkaratemans
  • 67
  • 1
  • 7

1 Answers1

0

Add an Application.DoEvents in your for loop to allow messages to be processed.

Panda
  • 448
  • 2
  • 8