In order to not show a form in C#.NET when first starting the application I have this:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
SomethingForm frmSomething = new SomethingForm();
Application.Run();
}
It is a one form application and the SomethingForm is the the parent form which has a Button to exit which currently calls the following Application.ExitThread();. This button is the only way to exit the application.
Now I know this is not graceful termination, but it was the only way I could get it to work when testing. It's now causing some problems with leaving the icon in the system tray after exit.
So how do I GRACEFULLY terminate this application?
or using:
Application.Exit()
anywhere in the code.
or
System.Environment.Exit(-1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With