We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

include how to tell if windows is trying to close the application or if the user is.

Your post about Setting a Form to Be Invisible at Its Inception was very helpful to me although it lacked the answer to that question. I have a program that can only be closed using the notify icon in the taskbar. The closed event is cancelled. I need to use application.exit() there but only when windows is trying to close the app to restart the computer.

2 Replies

Ramesh Praveen May 13, 2003 12:39 PM UTC

Maybe the Application.ApplicationExit will get called before your Closing event? -Praveen

Administrator May 30, 2003 01:07 PM UTC

This is what I had to do: public static void ShuttingDown() { StackTrace Trace = new StackTrace(true); if(Trace.FrameCount > 13) { if(Trace.GetFrame(14).GetMethod().Name=="WmSysCommand") { e.Cancel=true; this.Visible=false; } } }
Loader.
Live Chat Icon For mobile
Up arrow icon