C WinForm program completely exits the problem resolved

  • 2020-05-12 03:02:26
  • OfStack

1. this. Close (); Just close the current window, if not the main form, is unable to exit the program, in addition, if there is a managed thread (non-main thread), also can not exit cleanly;

2. Application. Exit (); Force all messages to abort and exit all forms, but if there is a managed thread (not the main thread), you cannot exit cleanly.

3. Application. ExitThread (); Force to abort all messages on the calling thread, also facing the problem that other threads cannot exit correctly;

4. System. Environment. Exit (0); This is the most thorough exit method, no matter what thread is forced to exit, the end of the program is very clean.

5. Application. Restar (); Log out to open a new instance


Related articles: