For most cases that handler should stay as it is. As a comment on that answer states, the handler declaration isn't even necessary. The following code for StartListening
should be sufficient:
((PropertyValue)source).Changed += DeliverEvent;
If you need to modify the values of s
and/or e
before delivering the event you can add that code to the handler you posted. But no matter what, DeliverEvent
must be called. It loops through and calls ReceiveWeakEvent
for all registered listeners and there's no way to get at the list of listeners unless you are storing them in your own ListenerList
. So, basically if you modify the event handler, it must still call DeliverEvent
or your weak event listeners will never be notified of the event.
If you posted the code you're trying to find a place for, it might be a little easier to help you figure out what you are trying to accomplish and where it should go instead.