Summarize unhandled exceptions in. NET Windows Form Application

Source: Internet
Author: User

In Windows Form application, if the exception is eventually not processed, the AppDomain.CurrentDomain.UnhandledException will be triggered Event to make the final exception record (using this event does not prevent the end of the application). Before this event is triggered, the following conditions can determine whether the exception continues to propagate.

Main thread

Use the application.setunhandledexceptionmode (BOOL) method to pre-set the processing mode:

    • If it is unhandledexceptionmode.throwexception, it continues to propagate.
    • If unhandledexceptionmode.catchexception, the Application.ThreadException event is used for capture processing, and if an exception is thrown in this event, it will continue to propagate.

tasks, including those created with the new task () and TaskFactory

You can use the taskscheduler.unobservedtaskexception event for capture processing (note that this event will not fire until garbage collection is complete) to set the observed value:

    • False indicates continued propagation
    • If true, the propagation will not continue.

custom threads, including those created with ThreadPool using the new thread ()

No

Summarize unhandled exceptions in. NET Windows Form Application

Related Article

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.