Are event subscribers called in order of subscription?

前端 未结 5 972
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 16:07

Is it safe to assume that event subscribers are called in order of subscription?
Example:

void One(object sender, EventArgs e) {}
void Two(object sende         


        
5条回答
  •  伪装坚强ぢ
    2020-12-09 16:44

    The quick answer would be "It's none of your business" :)

    An event is asynchronous by nature. This means that you are not waiting for an event to be fired or expecting it to occur at a given time. They just happen and then you take action. Wanting to know 'when' or trying to figure out 'how' is going to break this nature.

    Maybe in this case you don't need an event-based approach to get things done?

    What Jon Skeet said is technically correct for the current implementation, but maybe it won't in c#8.5 or VBasic 15.0. Relying on implementation details is always going to do more harm than good.

提交回复
热议问题