Preventing Exceptions from 3rd party component from crashing the entire application

前端 未结 3 1934
逝去的感伤
逝去的感伤 2021-02-04 08:27

I am writing a multi-threaded application that relies on some third party DLLs. My problem is that when using an object from the third party library, if it raises an exception w

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-04 09:03

    You can stop application crash by doing this:

        AppDomain.CurrentDomain.UnhandledException += (sender, e2) =>
        {
            Thread.CurrentThread.Join();
        };
    

    But uncaught exception from 3d party components mean that components don't do their job properly. If you don't care if they don't do the job better don't use them.

提交回复
热议问题