Why does the inner exception reach the ThreadException handler and not the actual thrown exception?

后端 未结 2 1993
梦毁少年i
梦毁少年i 2020-12-03 05:34

I\'m seeing some wierd behaviour when throwing exceptions and catching them in the Application.ThreadException event handler.

Basically whats happening

2条回答
  •  广开言路
    2020-12-03 06:19

            if (e.Error != null)
            {
                throw new Exception("worker_RunWorkerCompleted", new Exception("Inner", new Exception("Inner inner")));
            }
    

    You get "inner inner" at the end. It seems that this is the behavior of Application_ThreadException method to look at the inner-most exception.

提交回复
热议问题