How to get shutdown hook to execute on a process launched from Eclipse

I used the following hack at the end of my main method to get around the problem: if (Boolean.parseBoolean(System.getenv(“RUNNING_IN_ECLIPSE”))) { System.out.println(“You’re using Eclipse; click in this console and ” + “press ENTER to call System.exit() and run the shutdown routine.”); try { System.in.read(); } catch (IOException e) { e.printStackTrace(); } System.exit(0); }

handling phone shutdown event in android

You need to listen for the following intent action in your receiver: <action android:name=”android.intent.action.ACTION_SHUTDOWN” /> To make it compatible with some HTC (or other) devices which offer quick power-off feature, you need to include the following action too with in the same intent-filter: <action android:name=”android.intent.action.QUICKBOOT_POWEROFF” /> For more info, read this

How to simulate Windows shutdown for debugging?

There is a tool named Restart Manager (rmtool.exe) in the Microsoft’s Logo Testing Tools for Windows, which can be used to send shutdown and restart messages to a process. Logo testing tools can be downloaded here: http://download.microsoft.com/download/d/2/5/d2522ce4-a441-459d-8302-be8f3321823c/LogoToolsv1.0.msi Then you can simulate shutdown for your process: rmtool.exe -p [PID] -S where [PID] is the process ID. … Read more

How to shutdown an ExecutorService?

The typical pattern is: executorService.shutdownNow(); executorService.awaitTermination(); When calling shutdownNow, the executor will (generally) try to interrupt the threads that it manages. To make the shutdown graceful, you need to catch the interrupted exception in the threads or check the interrupted status. If you don’t your threads will run forever and your executor will never be … Read more

Close a WP7 application programmatically? [duplicate]

You can always call an exit by doing this at your landing page use this code on click of your application back button: if (NavigationService.CanGoBack) { while (NavigationService.RemoveBackEntry() != null) { NavigationService.RemoveBackEntry(); } } This will remove back entries from the stack, and you will press a back button it will close the application without … Read more

How do I shutdown, restart, or log off Windows via a bat file?

The most common ways to use the shutdown command are: shutdown -s — Shuts down. shutdown -r — Restarts. shutdown -l — Logs off. shutdown -h — Hibernates. Note: There is a common pitfall wherein users think -h means “help” (which it does for every other command-line program… except shutdown.exe, where it means “hibernate”). They … Read more