How do I properly exit a C# application?

I have a published application in C#. Whenever I close the main form by clicking on the red exit button, the form closes but not the whole application. I found this out when I tried shutting down the computer and was subsequently bombarded by lots of child windows with MessageBox alerts I added.

I tried Application.Exit but it still calls all the child windows and alerts. I don’t know how to use Environment.Exit and which integer to put into it either.

Also, whenever my forms call the FormClosed or FormClosing event, I close the application with a this.Hide() function; does that affect how my application is behaving?

4 Answers
4

Leave a Comment