Why do AppDomain exceptions invariably terminate the application?

前端 未结 3 902
-上瘾入骨i
-上瘾入骨i 2021-02-06 08:21

This is related to a previous question.

What I\'m trying to understand now is how come UI thread exceptions can be prevented from terminating the application while non-U

3条回答
  •  一整个雨季
    2021-02-06 08:28

    It's not that any AppDomain exception terminates the application, it's that unhandled exceptions (of any sort) will tear down the AppDomain and terminate the application.

    The issue here is that you can handle UI thread exceptions explicitly, at a fairly high level. However, when you have an unhandled exception in a background thread, there is no means of handling it easily at the same level, so it tends to propagate up and pull down the application. Application.ThreadException allows you to at least know that this is what caused the error, and log it if necessarily.

    Unhandled exceptions in the UI thread will cause the same thing to happen.

提交回复
热议问题