In my program I show a login form before the main form, once the program detects a successful login I use this:
MainForm Main = new MainForm();
Main.Show();
this.Hide();
This works fine but there is a problem, the login form is still open even though it is hidden so when the program is closed the process still hangs, how can I stop this from happening?
Sorry, forgot to add, using this.Close(); doesn’t work and will completely close the program.
You need to specify your
MainFormwhen you staring application and in theLoadevent handler of this form ask for login. In this case you will have runned application andLoginfor on the starting:Program.cs
MainForm.cs
P.S.
Closewill close your application completelly if it’s main form of your application.