exit

Intercept WM_CLOSE for cleanup operations

寵の児 提交于 2019-12-02 02:38:55
问题 I have an external application that calls my application and is supposed to end it when the job is done. The log from this external application claims it uses WM_CLOSE on my app. How can I intercept the WM_CLOSE message in my application to do some cleanup operations? I tried at_exit() and wrapping it in a class, but I think I have the wrong approach. 回答1: You could just handle WM_CLOSE in your message loop to do whatever cleanup is necessary, or even abort the close (by returning 1 instead

Intercept WM_CLOSE for cleanup operations

醉酒当歌 提交于 2019-12-02 02:16:25
I have an external application that calls my application and is supposed to end it when the job is done. The log from this external application claims it uses WM_CLOSE on my app. How can I intercept the WM_CLOSE message in my application to do some cleanup operations? I tried at_exit() and wrapping it in a class, but I think I have the wrong approach. You could just handle WM_CLOSE in your message loop to do whatever cleanup is necessary, or even abort the close (by returning 1 instead of 0). See e.g. this: http://cboard.cprogramming.com/windows-programming/141438-handling-wm_close-wm_destroy

How do I gracefully exit WinForms app when hitting stop debugging in VS?

拥有回忆 提交于 2019-12-02 02:12:29
问题 I'm writing a system tray Winforms app which does some very important cleanup on Application.ApplicationExit. When I hit the stop button while debugging in Visual Studio, this the process exits, but this cleanup code doesn't get called. Is there some way I can make sure it gets called in this situation? 回答1: No. When you hit the stop button you can expect your application to not execute anymore code (this allows you to exit infinite loops). If it executed more code, then the stop button would

Why isn't my WPF closing event being fired for system closes?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 02:01:25
问题 I have the following line in my Window stanza in the XAML file: Closing="Window_Closing" I originally thought that the web page here assured me that this event fires when you use the big X close method, Alt-F4 or close from the system menu yet that doesn't appear to be the case since my breakpoint on the Window_Closing() function isn't being hit. It does hit the breakpoint when I do the File , Exit method of exiting so that's working okay. Re-reading that linked page leads me to believe that

Handling Signals in an MPI Application / Gracefully exit

久未见 提交于 2019-12-02 01:16:10
How can signals be handled safley in and MPI application (for example SIGUSR1 which should tell the application that its runtime has expired and should terminate in the next 10 min.) I have several constraints: Finish all parallel/serial IO first befor quitting the application! In all other circumstances the application can exit without any problem How can this be achieved safely, no deadlocks while trying to exit, and properly leaving the current context jumping back to main() and calling MPI_FINALIZE() ? Somehow the processes have to aggree on exiting (I think this is the same in

Why isn't my WPF closing event being fired for system closes?

房东的猫 提交于 2019-12-02 00:49:57
I have the following line in my Window stanza in the XAML file: Closing="Window_Closing" I originally thought that the web page here assured me that this event fires when you use the big X close method, Alt-F4 or close from the system menu yet that doesn't appear to be the case since my breakpoint on the Window_Closing() function isn't being hit. It does hit the breakpoint when I do the File , Exit method of exiting so that's working okay. Re-reading that linked page leads me to believe that it may not trigger the closing event. My questions are: How do you catch the three methods listed in

How do I gracefully exit WinForms app when hitting stop debugging in VS?

*爱你&永不变心* 提交于 2019-12-01 23:38:14
I'm writing a system tray Winforms app which does some very important cleanup on Application.ApplicationExit. When I hit the stop button while debugging in Visual Studio, this the process exits, but this cleanup code doesn't get called. Is there some way I can make sure it gets called in this situation? No. When you hit the stop button you can expect your application to not execute anymore code (this allows you to exit infinite loops). If it executed more code, then the stop button would be a close button. The stop button allows you to kill your application without having to open taskman,

JUnit - stop it from exiting on finish?

99封情书 提交于 2019-12-01 21:10:55
Quick JUnit question. I'm running some unit tests that involve starting up the GUI and doing a load of stuff. I would like to see the results after the test to confirm it visually. However, it gets to the end of the code and exits, as it should. If I want to override this, I put a breakpoint on the last line of the test. This is pretty awkward though. Is there some option to stop it from exiting? Due to the fact you require a GUI and user interaction during the execution of the test, this is a "functional" test rather than a "unit" test. You could write the results to a file at the end, this

How to check exit if used tee?

前提是你 提交于 2019-12-01 19:24:08
I try to use tee to save output in file like: myapp | tee log.txt But I have a problem with checking of exit. Previous code: myapp if [ $? -eq 0 ] then ..... But $? will be exit of tee! Does it possible catch exit of myapp? Thanks. For bash, there's a convenient special array: PIPESTATUS. The return code for myapp would be in ${PIPESTATUS[0]} and so on. zsh has a roughly identical method. There's also a rather more annoying, hacky way to do it in strict bourne shells that you can read about in the comp.unix.shell FAQ . Use PIPESTATUS myapp | tee log.txt if [ $PIPESTATUS[0] -eq 0 ] then .....

iOS - detect when application exits

蓝咒 提交于 2019-12-01 19:18:11
How can I detect when a user exits the application? (hitting the home button) And how can I detect when the relaunch it? (clicking the icon) *I'm not talking about users manually quitting the app by holding the home button and then making the icons wiggle and deleting the app instance from the sub-dock. i'm talking about just temporarily exiting the app buy clicking the home button.. maybe sending a text or whatnot then coming back to the app. Thanks! - (void)applicationDidEnterBackground:(UIApplication *)application and - (void)applicationDidBecomeActive:(UIApplication *)application In your