الاثنين، ٢٧ أبريل ٢٠٠٩

Application.Exit vs Environment.Exit



System.Windows.Forms.Application.Exit()

Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed. This method stops all running message loops on all threads and closes all windows of the application. This method does not force the application to exit. The Exit method is typically called from within a message loop, and forces Run to return. To exit a message loop for the current thread only, call ExitThread. This is the call to use if you are running a WinForms application. As a general guideline, use this call if you have called System.Windows.Forms.Application.Run.

System.Environment.Exit(exitCode)
Terminates this process and gives the underlying operating system the specified exit code. This call requires that you have SecurityPermissionFlag.UnmanagedCode permissions. If you do not, a SecurityException error occurs. This is the call to use if you are running a console application.

System.Windows.Forms.Application.ExitThread()
Exits the message loop on the current thread and closes all windows on the thread.

ليست هناك تعليقات: