Should C# event handlers be exception safe?

后端 未结 6 1860
梦如初夏
梦如初夏 2021-02-05 07:14

Assuming that one event has multiple handlers, if any of event handlers throw an exception then the remaining handlers are not executed.

Does this mean that event handle

6条回答
  •  无人及你
    2021-02-05 07:55

    Why are event handlers are not like other patterns? What's the difference? Exception means that a subprogram tells to a caller that it can not work as it is designed to work. This means that the caller must do something with it. If a handler is performing some processing vital for the use case, then it is sensible that when it crushes, the rest of the program must stop.

提交回复
热议问题