Throwing exceptions in callback method for Timers

后端 未结 4 1606
醉酒成梦
醉酒成梦 2020-12-01 15:47

I was unable to find an answer to this question anywhere...

What happens with the exceptions thrown in the callback method for System.Threading.Timer, (or in the eve

4条回答
  •  醉梦人生
    2020-12-01 16:11

    I don't know what the best option is, but when I'm using a callback timer I'm normally throwing exceptions and letting them bubble up to the main callback routine, where I handle them gracefully. The thread continues to run on the timer as it should.

    Unhandled exceptions in the thread (System.Threading.Timer) will stop your entire program.

提交回复
热议问题