Home  >  Article  >  Backend Development  >  Exit method in C# application

Exit method in C# application

PHPz
PHPzforward
2023-08-30 21:45:021025browse

C# 应用程序中的退出方法

Environment.Exit() method

Environment.Exit() method terminates the process and returns an exit code to the operating system -

Environment.Exit(exitCode);

Use exitCode as 0 (zero) to show that the process completed successfully.

Use exitCode as a non-zero number to display errors, for example -

  • Environment.Exit(1) - a return value of 1 means you want The file does not exist

  • Environment.Exit(2) - A return value of 2 indicates that the file format is incorrect.

System.Windows.Forms .Application.ExitThread( )

To close a child application or the current thread in Windows Forms, use System.Windows.Forms .Application.ExitThread( ).

private void buttonClose_Click(object sender, EventArgs eventArgs) {
   System.Windows.Forms.Application.ExitThread( );
}

The above is the detailed content of Exit method in C# application. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete