Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Threading: How to open main form after thread is closed
    primarykey
    data
    text
    <p>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.</p> <p>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. </p> <p>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?</p> <p><strong>SPLASH SCREEN CODE</strong></p> <pre><code>public SplashScreen() { InitializeComponent(); } private void timer1_Tick(object sender, EventArgs e) { progressBar1.Increment(1); if (progressBar1.Value == 100) timer1.Stop(); } </code></pre> <p><strong>LOGIN START</strong></p> <pre><code>public LOGIN() { Thread t = new Thread(new ThreadStart(SplashScreen)); t.Start(); Thread.Sleep(5000); InitializeComponent(); t.Abort(); } public void SplashScreen() { Application.Run(new SplashScreen()); } </code></pre> <p><strong>LOGIN EXIT</strong> (Redirected to user's home page)</p> <pre><code>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(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload