I have a class that raises events that downstream objects subscribe to. In
one case, after destroying the object, the event seems to still get handled
in a subscriber object. So I instantiate an object and the event fires
correctly. Then I destroy the object and instantiate another instance and the
subscriber event handler get hit twice. I've tried using IDisposible and also
using GC.Collect, but it didn't seem to help. I've also tried using
RemoveHandler before destroying the object.
It's not clear to me whether the handler is firing because the objects are
still in memory or for some other reason.
Any help would be appreciated.
one case, after destroying the object, the event seems to still get handled
in a subscriber object. So I instantiate an object and the event fires
correctly. Then I destroy the object and instantiate another instance and the
subscriber event handler get hit twice. I've tried using IDisposible and also
using GC.Collect, but it didn't seem to help. I've also tried using
RemoveHandler before destroying the object.
It's not clear to me whether the handler is firing because the objects are
still in memory or for some other reason.
Any help would be appreciated.
Comment