If I have a console application, is there any way I can handle the following:
I know that if I was writing a unix application, I would handle various signals to catch the request to close (SIGTERM from memory), but I also know I need to handle these messages pretty quickly and exit before the system does a kill -9 (SIGKILL).
But for a C# console application, I'm not sure how to do this.
Session termination, such as when someone logs off
Handle the SystemEvents.SessionEnded event.
Process exit, such as when someone uses the task manager to close the application.
If you mean, if someone kills the application from the taskbar, I dont think you can handle that.
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