Say I have a class defined as:
class MyWrapper<T> where T : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChange(String propname)
{
handlePropertyChanged(this, new PropertyChangedEventArgs(propname));
}
private void handlePropertyChanged(object sender, PropertyChangedEventArgs e)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(sender, e);
}
}
private T _backing;
public MyWrapper(T backing)
{
_backing=backing;
_backing.PropertyChanged+=handlePropertyChanged;
}
...Reasons for wrapping the class...
}
This class sets a delegate on the PropertyChanged event on the backing object. From my understanding this delegate has a pointer to the instance of MyWrapper. Does this mean that instances of MyWrapper will have a lifetime no shorter than the baking object?
If so, is there a way around this?