I’m trying, but everything I’ve found so far seems to centre around GUI’s and form apps. That is not what I’m using.
Eventually it’ll be a service, but till it is done I’m running it as a normal app, the problem being that if I just close it by accident, it’ll leave another service hanging for up to 30 minutes with bad data. I though it would be easy to add a listener to catch the app being closed.
But I just can’t figure it out.
Here you have a perfect solution for what you need:
Detecting console application exit in c#
The code detects all the possible events that will close the application: