Application.Exit和End diffrence

时间:2015-10-20 19:52:00

标签: vb.net

你能简单解释一下这里的区别吗?我刚注意到,当我使用End时,我的整个应用程序立即关闭。什么是Application.Exit然后做什么和有什么区别?

1 个答案:

答案 0 :(得分:2)

The End statement calls the Exit method of the Environment class in the 
System namespace. Exit requires that you have UnmanagedCode permission. If you 
do not, a SecurityException error occurs.

参考:End statement

实际上,End会调用Environment.Exit,这会立即终止该程序。然而,Application.Exit在关闭之前处理待处理的消息。

Application.Exit

Informs all message pumps that they must terminate, and then closes all 
application windows after the messages have been processed.