Take the following C# class:
c1 {
event EventHandler someEvent;
}
If there are a lot of subscriptions to c1
's someEvent
event and I want to clear them all, what is the best way to achieve this? Also consider that subscriptions to this event could be/are lambdas/anonymous delegates.
Currently my solution is to add a ResetSubscriptions()
method to c1
that sets someEvent
to null. I don't know if this has any unseen consequences.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…