In one class, ClassA, I have a timer object. In this class I register the event handlers for the timer elapsed event. In another class, ClassB, I have a public event-handler for the timer elapsed event. So I register the event-handler from ClassB in ClassA as follows:
myTimer.Elapsed += ClassBInstance.TimerElapsed
What happens if I were to create a new instance of ClassBInstance and the timer elapsed event fires when the previous instance of ClassB's event-handler is still tied to the Elapsed event of the timer?
For example:
ClassB classBInstance = new ClassB();
myTimer.Elapsed += classBInstance.TimerElapsed
classBInstance = new ClassB();
myTimer.Elapsed += classBInstance.TimerElapsed