I wrote a C # Windows Forms application, not a service (it is used only when the user is logged in and has a graphical user interface) that has a background thread that runs in an endless loop.
However, when I try to turn off Windows (7), it tells me that the program does not allow it to shut down or exit the system and asks me if I want to force shutdown.
Now, is it possible for my program to recognize (get a handler) Windows trying to exit it or exit the system?
So, I need the application to be implemented when Windows tries to exit.
Thanks in advance.
EDIT: Thanks for the great tip! Is there any way to use the idea with a form closing event if it has a CANCEL event handler?
source share