exit

How can I tell my Cocoa application to quit from within the application itself?

耗尽温柔 提交于 2019-12-03 04:13:55
问题 I'm looking for a good way to tell my Cocoa application to quit itself. Rest assured that this will not be used for production code. I'm just looking for an easy way to run one test and then close the application during debugging. I have found that exit(0); will close the app, but it bypasses all of the normal application exit procedures, and I would like to keep all of them in place. Essentially I want things to work as if a user pulled "Quit" from the menu, but I want it to happen

Does Application.ApplicationExit event work to be notified of exit in non-Winforms apps?

孤街醉人 提交于 2019-12-03 03:40:29
Our code library needs to be notified when the application is exiting. So we have subscribed to the System.Window.Forms.Application.ApplicationExit event. This works nicely for Winforms apps, but does it also work for other types of applications such as console apps, services, and web apps (such as ASP.NET)? The namespace would suggest that it doesn't, and it presumably gets raised when Application.Exit() is called (explicitly or implictly), which may not be correct to call for these other cases. Is there some other event which would be better in these other cases or which would be more

Exit/Finish an app/activity - android

主宰稳场 提交于 2019-12-03 01:56:34
I've got 4 activities say Act1 , Act2 , Act3 and Act4 . A button in Act1 opens Act2, a button in Act2 opens Act3, a button in Act3 opens Act4. I want two things to be done: I've a button in Act4 which directs the user to Act1, the prob is when the user clicks back in Act1, i want to close the app instead of opening the Act4.. I've option in menu 'exit' in all activities when the user choose it, i want to close the app instead of going back to previous activity. Tried using finish(); but it didn't meet my requirements. Use below code in your Act4 'th Menu.xml 's exit button - Intent intent =

Exit a Script On Error

社会主义新天地 提交于 2019-12-03 01:23:55
问题 I'm building a Shell Script that has a if function like this one: if jarsigner -verbose -keystore $keyst -keystore $pass $jar_file $kalias then echo $jar_file signed sucessfully else echo ERROR: Failed to sign $jar_file. Please recheck the variables fi ... I want the execution of the script to finish after displaying the error message. How I can do this? 回答1: Are you looking for exit? This is the best bash guide around. http://tldp.org/LDP/abs/html/ In context: if jarsigner -verbose -keystore

EXIT_FAILURE vs exit(1)?

孤者浪人 提交于 2019-12-03 00:51:57
问题 What's the difference? Which is preferred, or when should I use each one respectively? 回答1: exit(1) (usually) indicates unsuccessful termination. However, its usage is non-portable. For example, on OpenVMS, exit(1) actually indicates success. Only EXIT_FAILURE is the standard value for returning unsuccessful termination, but 1 is used for the same in many implementations. So to summarize: If you want to write perfectly portable code use, EXIT_FAILURE for failure case. While, You can use

面向对象实现石头剪刀布游戏

匿名 (未验证) 提交于 2019-12-03 00:42:01
1 import random 2 import time 3 4 5 class Player: 6 def __init__ (self): 7 self.name = " 老张 " 8 self.fist = " 你这样会报错 " 9 self.score = 0 10 11 def player_name(self): 12 name_choice = [ ‘ 喜洋洋 ‘ , ‘ 美洋洋 ‘ , ‘ 懒洋洋 ‘ ] 13 input_name = input( " 请选择人物:1喜洋洋 2美洋洋 3懒洋洋(输入exit退出): " ) 14 if input_name == " exit " : 15 self.name = " exit " 16 else : 17 18 if input_name == " 1 " : 19 self.name = name_choice[0] 20 elif input_name == " 2 " : 21 self.name = name_choice[1 ] 22 elif input_name == " 3 " : 23 self.name = name_choice[2 ] 24 # self.player_fist() 25 print ( " 你选择了{} " .format(self.name)) 26 27 def

why socket on the receiving peer keep receiving '' infinitely when I use “control-c” to close the socket on the sending peer

╄→гoц情女王★ 提交于 2019-12-02 23:43:31
问题 I'm a newbie to socket programming, I know it's a bad habit to close socket using "control-c", but why socket on the receiving peer keeps receiving '' infinitely after I use "control-c" to close the sending process? shouldn't the socket on the sending peer be closed after "control-c" to exit the process? Thanks! 回答1: I know it's a bad habit to close socket using "control-c" That closes the entire process, not just a socket. why socket on the receiving peer keeps receiving '' infinitely after

continue break exit(0) return 的用法和区别

匿名 (未验证) 提交于 2019-12-02 23:26:52
continue break exit(0) return 的用法和区别 break: 负责终止离它最近的while、do while、for或switch语句,并从这些语句之后的第一条语句开始继续执行。break语句只能出现在迭代语句或者switch语句内部(包括潜逃在此类循环里的语句或块的内部)。break语句的作用范围仅限于最近的循环或者switch。 continue: 终止最近的循环中的当前迭代并立即开始下一次迭代。continue语句只能出现在for、while、和do while循环内部,或者嵌套在此类循环里的语句或者块的内部。和break语句类似的是,出现在嵌套循环中的continue语句也仅作用于离它最近的循环。和break语句不同的是,只有当swith语句嵌套在迭代语句内部时,才能在switch里使用continue。 return: 终止当前函数的执行。 exit(0): exit 函数将无条件地关闭程序。因为它绕过了程序的正常逻辑流程,所以应该谨慎使用它。有时候会出现一些非常少见的情况,使得程序有必要在 main 以外的函数中终止。要实现这一点,可以使用 exit 函数。要使用 exit 函数,必须包含 < c s t d l i b > <cstdlib> < c s t d l i b > 头文件。请注意,该函数采用整数实参

Exit with error code in go?

北城以北 提交于 2019-12-02 23:20:38
What's the idiomatic way to exit a program with some error code? The documentation for Exit says "The program terminates immediately; deferred functions are not run.", and log.Fatal just calls Exit . For things that aren't heinous errors, terminating the program without running deferred functions seems extreme. Am I supposed to pass around some state that indicate that there's been an error, and then call Exit(1) at some point where I know that I can exit safely, with all deferred functions having been run? I do something along these lines in most of my real main packages, so that the return

python3环境管理器

匿名 (未验证) 提交于 2019-12-02 22:56:40
1. 类内有 __enter__ 和 __exit__ 方法的类被称为环境管理器 2. 能够用with语句进行管理的对象必须是环境管理器 3. __enter__ 将在进入with语句时调用并返回由 as 变量管理的对象 4. __exit__ 将在离开with时被调用,且可以用参数判断离开with语句时是否有异常发生,并做出相应的处理 class Door: def open_door(self): print("正在开门") def close_door(self): print("正在关门") def come_in(self): print("正在进人") def __enter__(self): self.open_door() return self #对象被as绑定(开门的动作被c绑定) def __exit__(self, exc_type, exc_val, exc_tb): self.close_door() if exc_type is None: print("with语句正常退出") else: print("with语句异常退出",exc_value) with Door() as c: c.come_in() 3 / 0 #抛出一个异常 c.come_in() __enter__语句在with执行时调用 open_door 动作,在with执行完毕调用