exit

Issue with Process Exited

拜拜、爱过 提交于 2019-12-05 03:23:26
lets say I have a process with the ID 1234. This process is running before my application runs. I have this code: Process app = Process.GetProcessById(1234); MessageBox.Show(app.MainWindowTitle); app.Exited += this.methodShowsMessageBox; Now, when I compile and run the app, it gets the process and shows the main window title. However when i close process 1234, the app.Exited does nto fire... why is this? And how would i get it to fire? Please note that the documentation states that EnableRaisingEvents must be set to true before this event will fire. By default, for performance reasons, the

How to create a correct exit button in qt

旧街凉风 提交于 2019-12-05 02:51:19
I'm trying to create an exit button that correctly closes the GUI I have made in QT. I have tried doing this in the following way: #include <QtGui/QApplication> #include "mainwindow.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); int window_width = QApplication::desktop()->width(); int window_height = QApplication::desktop()->height(); MainWindow w; QPushButton * quit_btn = new QPushButton; quit_btn->setParent(w.centralWidget()); quit_btn->setGeometry(window_width-50,12,32,32); QObject::connect(quit_btn,SIGNAL(clicked()),qApp,SLOT(quit())); w.resize(window_width,window_height

C: Doing something when the program exits

风流意气都作罢 提交于 2019-12-05 02:42:04
In C, if my application ends unexpectedly can I call a function before that happens? I'm writing a flag into a database (processRunning = 1) that prevents other applications from starting a similar process. When the application ends it would not change that flag back. look into the atexit API of the C standard library. On POSIX, the proper solution is to protect the data with a robust mutex in shared memory. If your process has died with a robust mutex held, another program trying to lock the mutex will not deadlock but will instead return EOWNERDEAD , and then it has the opportunity to clean

VB 6 crash on exit

社会主义新天地 提交于 2019-12-05 02:24:44
问题 I have a legacy vb6 app that crashes on exit - both as an executable and in the IDE. How can I avoid the crash? I am currently unloading the forms (except the frmmain) in form_unload , releasing all the ADODB RecordSets, setting all the boundcollections = nothing. I have attempted to SetErrorMode SEM_NOGPFAULTERRORBOX in the form_terminate event and that has not stopped the error from occurring. I have also checked for subclasses being instantiated in my code and found none. I have checked

System.exit(0) vs JFrame.EXIT_ON_CLOSE

[亡魂溺海] 提交于 2019-12-05 01:42:46
Is there any difference between the two. I was reading an article ( http://www.javalobby.org/java/forums/t17933 ) about that you should always use System.exit(0); Currently I use JFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); The article says that even for a Java Swing Application you should add a listener WindowAdapter and and call System.exit() inside its method windowClosing(WindowEvent e) . Is there any difference? Is one method better then the other? If you look at the JFrame code, it does: protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e

Can build, but can't run C code in netbeans (but it works in command line)

有些话、适合烂在心里 提交于 2019-12-05 00:02:57
when I try Building the .exe of my code in C inside NB it makes it successful, but when I try to run it inside the program I always get this error: Unable to start pty process: RUN FAILED (exit value -2, total time: 31ms) But when I go inside the Run proprieties of the project and set the "Console Type" parameter to "External Terminal" it runs in the command line OK. Any idea about what it could be? I am working with cygwin. I fixed the problem going to Properties Project -> Run -> Console Type -> External Terminal. In this way you can compile using Netbeans. If you are working on netbeans

Bash: One-liner to exit with the opposite status of a grep command?

做~自己de王妃 提交于 2019-12-04 22:18:16
How can I reduce the following bash script? grep -P "STATUS: (?!Perfect)" recess.txt && exit 1 exit 0 It seems like I should be able to do it with a single command, but I have a total of 3 here. My program should: Read recess.txt Exit 1 (or non-zero) if it contains a line with "STATUS: " of NOT "Perfect" Exit 0 if no such line exists (i.e. all "STATUS: " lines are "Perfect") The answer award goes to the tightest script. Thanks! Example files Program should have exit status 0 for this file: FILE: styles.css STATUS: Perfect! FILE: contour-styles.css STATUS: Perfect! Program should have exit

Bind command to X-button of window title bar

北战南征 提交于 2019-12-04 21:54:25
My WPF maintenance window have a toolbar with a button "Exit"; a CommandExit is bind with this button. The CommandExit perform some checks before exit. Now, if I click to close button of the window (x-button of title bar), this checks are ignored. How can I do to bind CommandExit to window x-button? You have to implement event handler of your main window's event "Closing" where you can do checks and cancel the closing action. This is easiest way to do it, however otherwise you have to redesign whole window and its theme. I assume you may want to cancel closing based on these conditions? You

Terminate python threads using sys.exit()

大憨熊 提交于 2019-12-04 20:01:23
I am looking for a way to terminate a thread by using sys.exit(). I have two functions add1() and subtract1() , which are executed by each thread t1 and t2 respectively. I want to terminate t1 after finishing add1() and t2 after finishing subtract1() . I could see that sys.exit() do that work. Is it ok to do in such way? import time, threading,sys functionLock = threading.Lock() total = 0; def myfunction(caller,num): global total, functionLock functionLock.acquire() if caller=='add1': total+=num print"1. addition finish with Total:"+str(total) time.sleep(2) total+=num print"2. addition finish