I'd like to rebind the alt f4 shortcut so that it saves the calculated data before leaving. It would avoid me having to save it on every loop. I'm not lookinig for a 3rd party program because I would like that the user don't have to do it manually.
Asked
Active
Viewed 77 times
0
-
1Have you considered the case where the program quits unexpectedly, such as due to loss of power or system crash? You may want to include some sort of auto save to account for that. As for running a save on application shutdown, rather than rebind ALT F4, you can [add a shutdown hook](https://stackoverflow.com/q/2921945/1247781) that will run at program termination. – FThompson Aug 16 '18 at 05:27
-
I think it'd be better, you're right. I'm gonna take a look at it thanks :) does it work even when the shut down is intentional ? – Iyopl Aug 16 '18 at 05:40
-
As far as I'm aware, the shutdown hook will run during any clean application termination, such as by pressing the X, using `System.exit`, or pressing ALT F4. Situations where it would not run, on the other hand, include terminating the process via task manager or pulling power from the computer. I believe the shutdown hook would also run if you shut down your computer properly with the process running (leaving it enough time to terminate itself properly) but you'd need to test this to be sure. – FThompson Aug 16 '18 at 05:44
-
Okay thanks a lot :) – Iyopl Aug 16 '18 at 05:55