C # force exit

Source: Internet
Author: User

To prevent users from exiting the system abnormally, set E. Cancel = true in the formclosing event of the form.

However, the result is that if a user wants to quit, the user cannot quit. The solution is to use a variable that can exit for analysis. For example, we can set iscanexitProgramSet iscanexit to true when you can exit, which is troublesome.

In addition, this situation also occurs when multithreading is used. At that time, neither application. Exit nor apllication. exitthread can be used to completely exit the system. Although the program interface has exited, the process is still running in the task manager.

This indicates that application. Exit or apllication. exitthread cannot be used to completely exit.

Later, we found that in addition to the preceding two exit methods, there is also an environment. Exit method, which can be called to completely exit the system.

At this time, it is not difficult to find that even if our program cannot exit normally, but when debugging, click the stop button in vs2005 and it will end, in the task manager, we cannot see the environment. the exit method should have the same effect as the stop button in vs2005.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.