I have 2 forms: signin and control_panel. After signin done I’m hiding this form by this.Hide() function and same time I am making new object of control_panel form and showing it by newobj.Show();. But when I am closing directly control_panel form, I am seeing first form thread are still running. I am closing it by stop_debugging button. How will I close every threads or whole program exit simultaneously.
I have 2 forms: signin and control_panel . After signin done I’m hiding this
Share
The thread for your first form is still running because you’re only calling
this.Hide. All that does is hide the form; it doesn’t close it. Instead, you need to usethis.Close, which will close your original form.If you want to make sure that your entire application exits, and in the process close any forms that may still be open, you can use the
Application.Exitmethod anywhere in your form’s code.EDIT: To expand on my last comment, you might want something like this in your
Program.csfile: