application-shutdown

How to restart an application completely?

无人久伴 提交于 2019-11-30 19:25:58
I have an application which starts a Remote Service in its first launched activity. Then, in another activity, the user can set the configuration of the application. Please note that this second activity isn't bound to the Service and I don't wish to bind it. Now my question is : how could I restart the whole application from the second activity, after changing the configuration settings? For now, I am using a button which onClickListener is : public void onClick(DialogInterface dialog, int which) { sauvegarde(); Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage

Is there a C++ function to turn off the computer?

丶灬走出姿态 提交于 2019-11-30 16:12:26
Is there a C++ function to turn off the computer? And since I doubt there is one (in the standard library, at least), what's the windows function that I can call from C++? Basically, what is the code to turn off a windows xp computer in c++? On windows you can use the ExitWindows function described here: http://msdn.microsoft.com/en-us/library/aa376868(VS.85).aspx and here's a link to example code that does this: http://msdn.microsoft.com/en-us/library/aa376871(VS.85).aspx Use the following, assuming you have the privileges): ExitWindowsEx (EWX_POWEROFF | EWX_FORCEIFHUNG, SHTDN_REASON_MINOR

Is there a C++ function to turn off the computer?

北城以北 提交于 2019-11-30 16:06:09
问题 Is there a C++ function to turn off the computer? And since I doubt there is one (in the standard library, at least), what's the windows function that I can call from C++? Basically, what is the code to turn off a windows xp computer in c++? 回答1: On windows you can use the ExitWindows function described here: http://msdn.microsoft.com/en-us/library/aa376868(VS.85).aspx and here's a link to example code that does this: http://msdn.microsoft.com/en-us/library/aa376871(VS.85).aspx 回答2: Use the

How to save variables after application shut down?

帅比萌擦擦* 提交于 2019-11-30 15:36:08
I want to save some integers after application shut down and restore them after application opening, what is the easiest way to do this? You should store and load data from NSUserDefaults: http://developer.apple.com/library/IOS/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; // to store [defaults setObject:[NSNumber numberWithInt:12345] forKey:@"myKey"]; [defaults synchronize]; // to load NSNumber *aNumber = [defaults objectForKey:@"myKey"]; NSInteger anInt = [aNumber intValue];

Application.Current.Shutdown() doesn't

可紊 提交于 2019-11-29 14:29:00
问题 Title's about it. WPF app with some WCF stuff for IPC. I call Application.Current.Shutdown() and the app continues on happily. I thought Shutdown was supposed to be unstoppable. Perhaps because it's being called from a background thread? Do I need to do some dispatcher fiddling? 回答1: You get an exception when I call Application.Current.Shutdown in any thread other than the main one, so I'd assume you where using "dispatcher fiddling" properly already. In any case, this compiles and quits an

Python - How to detect when user closes a console application via “X” button

China☆狼群 提交于 2019-11-29 14:28:28
I currently have a Console based python program running under windows. The program maintains most of its data in memory and periodically saves the data to disk, or when the user shuts the application down via a Keyboard interrupt ( Ctrl + C ) event. The problem i have is that when a user hits the "X" button at the top right of the console window, the session closes and the data in memory is lost. What i am looking for is an event/signal or hook so that i can clean up the memory before closing down. I am hoping to do this without any external libraries, though if this is not possible i'd still

What is the correct way to add a Shutdown Hook for an Eclipse RCP application?

人走茶凉 提交于 2019-11-28 09:26:20
I have an RCP application that uses a connection to a in-memory database. There is one circumstance that, when shutting down windows, the application is killed without giving it a chance to close the connection to the database. I researched a little and it seems that adding a Shutdown hook is the best way to detect this event and do cleanup in a Java application. However, what is the correct way to do process this if you have an RCP application, possibly with multiple editors open? Note: this blog entry suggests the following implementation for the shutdown hook: The shutdown code must be run

Python - How to detect when user closes a console application via “X” button

懵懂的女人 提交于 2019-11-28 08:26:09
问题 I currently have a Console based python program running under windows. The program maintains most of its data in memory and periodically saves the data to disk, or when the user shuts the application down via a Keyboard interrupt ( Ctrl + C ) event. The problem i have is that when a user hits the "X" button at the top right of the console window, the session closes and the data in memory is lost. What i am looking for is an event/signal or hook so that i can clean up the memory before closing

contextDestroyed() vs addShutdownHook()

六眼飞鱼酱① 提交于 2019-11-28 08:07:25
问题 I'm currently implementing ServletContextListener and using contextDestroyed() to run cleanup tasks on my web application before it shuts down. However, I've been reading about how Runtime.addShutdownHook(Thread) can be used for the same purpose. Is there any difference between these two methods of running cleanup before undeployment? Which is preferable for a web application, in terms of functionality, efficiency, and maintainability? 回答1: I think the ServletContextListener is more

Shutting down a WPF application from App.xaml.cs

a 夏天 提交于 2019-11-28 06:45:01
I am currently writing a WPF application which does command-line argument handling in App.xaml.cs (which is necessary because the Startup event seems to be the recommended way of getting at those arguments). Based on the arguments I want to exit the program at that point already which, as far as I know, should be done in WPF with Application.Current.Shutdown() or in this case (as I am in the current application object) probably also just this.Shutdown() . The only problem is that this doesn't seem to work right. I've stepped through with the debugger and code after the Shutdown() line still