Application.Run

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am developing a windows form with a login screen.Once a user succesfully
logs in,I want to close the login screen and run the main application.

I dont want to use show dialog box.I would like to use application.run for
both the forms.

Please let me know what is a good way to do it.
Any help is highly appreciated.

Thanks
 
In order to open the second form using the Application.Run, once the user
successfully logs in, exit from the thread on which login form is running
using
'Application.ExitThread()' and spawn a new thread. The thread will be
spawned using System.Threading.Thread. Now another form can be run using
Application.Run on newly spawned thread.

Sample Code:
The following code for the button click event of the 'login button' enables
the user to log in and run the second form using Application.Run as well.


System.Threading.Thread td;
private void button1_Click(object sender, EventArgs e)
{

if(this.textBox1.Text=="a" && this.textBox2.Text=="a")
{


Application.ExitThread();
Thread td = new Thread(new ThreadStart(ss));
td.Start();

}

}
protected void ss()
{
MessageBox.Show("new thread is running");
Application.Run(new Form2());
}
 
Back
Top