Forgive me if this question is a duplicate of others, I probably do not know how to word out my problem correctly that's why I could not find the appropriate answer.
I have a winforms C# application with multiple forms. My main form is a login form, prior to it is a splash screen which loads first. My problem is that whenever I click logout, I want it to return to the login screen. However, the splash screen loads and does not open the login form anymore.
I suspect that this is because I started a new thread to be able to close the mainform and open the next form? I read it somewhere that I have to do that because an error occurs when merely using main.close() and form1.show(). Help?
SPLASH SCREEN CODE
public SplashScreen()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.Increment(1);
if (progressBar1.Value == 100) timer1.Stop();
}
LOGIN START
public LOGIN()
{
Thread t = new Thread(new ThreadStart(SplashScreen));
t.Start();
Thread.Sleep(5000);
InitializeComponent();
t.Abort();
}
public void SplashScreen()
{
Application.Run(new SplashScreen());
}
LOGIN EXIT (Redirected to user's home page)
public static void OpenHomeAdmin() // new thread to open home ADMIN
{
Application.Run(new Home_Admin());
}
if (usertype == "UT1") //admin rights
{
//GET LOGGED USER
Home_Admin homeAdmin = new Home_Admin();
homeAdmin.SetUsername(username);
this.Close();
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(OpenHomeAdmin));
t.Start();
}