1 This . Close (); // Close the current form or object
2
3 Application. Exit (); // Close all applicationsProgramWindow
4
5
If multithreading is enabled, use the following method to disable it.
C # using application. Exit (); you cannot exit a separate thread.
Environment. Exit (0); can solve the problem.
The following method is disabled for reference only.
1 /// <Summary>
2 /// Stop a process
3 /// </Summary>
4 /// <Param name = "processname"> Process name </Param>
5 Public Static Void Stopprocess ( String Processname)
6 {
7 Try
8 {
9 System. Diagnostics. Process [] PS = System. Diagnostics. process. getprocessesbyname (processname );
10 Foreach (System. Diagnostics. PROCESS p In PS)
11 {
12 P. Kill ();
13 }
14 }
15 Catch (Exception ex)
16 {
17 Throw Ex;
18 }
19 }
20
21
This process name is the name of your executable file, such as abc.exe
Enter the process name ABC.
The following method has not been tried:
// Add the following to the form close event:Code
1 If ( This . Thread ! = Null | This . Thread. isalive)
2 {
3 This . Thread. Abort ();
4 This . Thread = Null ;
5 }