exit

Wait for process to end async and then call a function within the main form

≡放荡痞女 提交于 2019-12-31 05:59:31
问题 I'm coding an editor for a game with C#. My programm openes as .txt File by starting a notepad.exe process. If that process exits, I want to call a function within the main form (to update the textbox). Here's what I'm doing so far: void OpenTextEditor(TreeNode node) { Process editor = new Process(); editor.StartInfo.WorkingDirectory = "%WINDIR%"; editor.StartInfo.FileName = "notepad.exe"; var txtfilelocation = GetRealPathByNode(node); var txtfile = File.ReadAllText(txtfilelocation,Encoding

JUnit - stop it from exiting on finish?

孤人 提交于 2019-12-31 01:45:19
问题 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? 回答1: Due to the fact you require a GUI and user interaction during the execution of the test,

Terminating or aborting an HTTP request

北战南征 提交于 2019-12-30 22:53:04
问题 What's the way to abort my API serving with some error message? Link to call my service: http://creative.test.spoti.io/api/getVastPlayer?add= {"Json":Json}&host=api0.spoti.io&domain=domain&userAgent=userAgent&mobile=true To call my service the client need to send a Json and some params. I want to test if the params that I get are correct, if not I want send a error message. The response should be a Json Code {"Result":"Result","Error":"error message"} I tried log.fatal and os.Exit(1) they

Terminating or aborting an HTTP request

时光总嘲笑我的痴心妄想 提交于 2019-12-30 22:52:35
问题 What's the way to abort my API serving with some error message? Link to call my service: http://creative.test.spoti.io/api/getVastPlayer?add= {"Json":Json}&host=api0.spoti.io&domain=domain&userAgent=userAgent&mobile=true To call my service the client need to send a Json and some params. I want to test if the params that I get are correct, if not I want send a error message. The response should be a Json Code {"Result":"Result","Error":"error message"} I tried log.fatal and os.Exit(1) they

C++ how do I terminate my programm using ESC button

被刻印的时光 ゝ 提交于 2019-12-30 11:09:24
问题 Here is my main function i use visual studio 2012 express and the code works fine. My question is how will i terminate this loop when the user Presses the ESC button instead of -1. Although i would prefer a solution that works both in unix and windows, if it is not possible i am most interested in it working for windows. int _tmain(int argc, _TCHAR* argv[]) { list mylist; int value; cout<<"Give the numbers you want to insert to the list, press -1 to stop\n"; do { cin>>value; mylist.insertf

Clean up before closing the QCoreApplication

风格不统一 提交于 2019-12-30 09:36:11
问题 I have a console-based QCoreApplication which has timers and does socket communication and also uses locked mutex. When I close the application manually, it gives error saying some mutex is locked and it is timed out. Is there any way I can do clean up in a console application when user closes it? 回答1: Cleanup should be handled by destructors and child-parent relationship. Make your master object (the one in the main) a child of QApplication so it is destructed with all its childs before

Exit application on “Back” button on WP7

被刻印的时光 ゝ 提交于 2019-12-30 09:06:34
问题 I know that in WP7 it is not possible to exit application programatically. So haw can I handle the following need? My MainPage is empty, and has has the only purpose to make a test: if user never filled a preference page, redirects to Page_B.xaml (a page which collects his preferences, such as language aond other info which are needed in order to run the app). Otherwise redirect to Page_A.xaml. So the first page that user is shown is either Page_A or Page_B (depending if this is the first

Difference between return 1, return 0, return -1 and exit?

醉酒当歌 提交于 2019-12-29 10:17:10
问题 For example consider following code: int main(int argc,char *argv[]) { int *p,*q; p = (int *)malloc(sizeof(int)*10); q = (int *)malloc(sizeof(int)*10); if (p == 0) { printf("ERROR: Out of memory\n"); return 1; } if (q == 0) { printf("ERROR: Out of memory\n"); exit(0); } return 0; } What does return 0 , return 1 , exit(0) do in the above program? exit(0) will exit total program and control comes out of loop but what happens in case of return 0 , return 1 , return -1 . 回答1: return from main()

How to make Java program exit after a couple of seconds

断了今生、忘了曾经 提交于 2019-12-29 07:11:35
问题 Is there anyway I can exit a java program after a couple of seconds e.g. 5 seconds. I know you can quit the java program using: System.exit(0); But I'm not sure whether the 0 stands for seconds since this code: System.exit(10); also exits instantly 回答1: System.exit(0) specifies the exit error code of the program. you can put it on a timer and schedule the task import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class TimedExit { Timer timer = new Timer();

Why is the exit code 255 instead of -1 in Perl?

陌路散爱 提交于 2019-12-28 04:26:07
问题 Why is it that when I shift the exit code, $?, in Perl by eight, I get 255 when I expect it to be -1? 回答1: The exit status returned by 'wait()' is a 16-bit value. Of those 16 bits, the high-order 8 bits come from the low-order 8 bits of the value returned by 'exit()' — or the value returned from main() . If the program dies naturally, the low-order 8 bits of the 16 are all zero. If the program dies because of signal, the low-order 8 bits encode the signal number and a bit indicating whether a