private void Splash_FormClosed(object sender, FormClosedEventArgs e) { if (StressForm != null && StressForm.Visible) { StressForm.Invoke(new Action(() => { if (StressForm != null) { StressForm.TopMost = true; Application.DoEvents(); StressForm.TopMost = false; } })); } StressForm = null; }
void FadeOut() { if (InFadeOut) { return; } if (SystemInformation.TerminalServerSession) { if (Startup) { Application.ExitThread(); } StressForm = null; base.Close(); return; } int duration = 500;//in milliseconds int steps = 50; Timer timer = new Timer(); timer.Interval = duration / steps; timer.Enabled = true; int currentStep = steps; timer.Tick += (arg1, arg2) => { Opacity = ((double)currentStep) / steps; currentStep--; if (currentStep <= 0) { timer.Stop(); timer.Dispose(); if (Startup) { Application.ExitThread(); } Visible = false; if (StressForm != null && StressForm.Visible) { StressForm.Invoke(new Action(() => { if (StressForm != null) { StressForm.TopMost = true; Application.DoEvents(); StressForm.TopMost = false; } })); } StressForm = null; base.Close(); } }; timer.Start(); }