I have a MVVM application in WPF. I have an event that gets dispatched from a static instance of a class.
When a given condition occurs, I need to listen for the next occurrence of said event. I do this with the following code:
myInstance.OnData += myEventHandlerInstance;
The event handler is removed at a later time, but as soon as it is added, the event handlers in the other view models no longer execute. I have verified that the dispatcher is the same instance in all places where the event is fired and handled (using the methods described below).
Why does the existing handler not get executed?
Thanks for the help everyone. You helped me focus in on the problem. The problem was purely a structure/logic issue, I was able to dig deeper into the code.