he-the-great/Juno-Windows-Class-Library — Issue #5: Handling of unadvising in com.client.EventProvider
Author: Numpsy
Created: 2011-11-08 22:05:30+00:00
State: open

The com.client.EventProvider class tries to call Unadvise in its destructor, but this is a bit dodgy as the class will never be destroyed as long as it is advised on something (When you call Advise the object that you're advising on AddRefs your class and keeps hold of it, and then calls Release() when you Unadvise).

I've changed my local copy to move the code from the destructor into a disconnect() method, which my client code calls when it's finished. This is a bit more manual but seems the most straight forward approach, though my knowledge of advise sinks is a bit hazey.

Anyone got any opinions?