I have shown a splash screen it works fine, but the main form will not shown on task bar and focus.
There are 2 form 1. SplashScreen 2. formMain
On splashscreen I added a timer and do some code below.
public SplashScreen()
{
InitializeComponent();
}
private void splashtimer_Tick(object sender, EventArgs e)
{
progressBar1.Increment(1);
if (progressBar1.Value == 100) splashtimer.Stop();
}
On the main form "formMain"
I added the code below.
public formMain()
{
this.ShowInTaskbar = true;
Thread t = new Thread(new ThreadStart(ShowSplashScreen));
t.Start();
Thread.Sleep(5000);
InitializeComponent();
t.Abort();
}
public void ShowSplashScreen()
{
Application.Run(new SplashScreen());
}
Splash screen works fine but the main form will not focus. I run EXE from Debug folder and run it, splash screen displayed and main form not sown. Taskbar icon not shown. When in Ctrl+tab the formMain is shown. Why???
Where is the problem?
Thread.Abort()
unless you are trying to forcibly shut down your entire app. It can leave the process in an undefined state. – Enigmativityss = new SplashScreen()
and callss.Invoke((Action)(() => ss.Close()));
instead. – Enigmativity