Exceptions in multithreaded application.

前端 未结 10 1569
春和景丽
春和景丽 2021-02-15 00:02

I have heard from a very discerning person that an exception being thrown (and not caught) in a thread is being propagated to the parent thread. Is that true? I have tried some

10条回答
  •  面向向阳花
    2021-02-15 00:28

    The thread's exception will not propogate to the main thread's context. This really makes sense - by the time the exception is thrown, the main thread will typically be in a completely different scope than the one containing your exception handler.

    You can catch these exceptions (typically to log them) by hooking into AppDomain.UnhandledException. See that page for details, including differences in Windows Forms applications, etc.

提交回复
热议问题