Hi,
When I use this method http://stackoverflow.com/questions/1089309/weak-events-in-net (by Egor) to hook up a event i a inherited treenode, the tree node never gets collected, is there any speciall case with tree nodes and GC?
public class MyTreeNode : TreeNode
{
public MyTreeNode(Entity entity)
{
entity.Children.ListChanged += new ListChangedEventHandler(entityChildren_ListChanged).MakeWeak(eh => entity.Children.ListChanged -= eh);
}
}
Entity.Children is a bindinglist.
I made tests with a destructor on MyTreeNode and invoking GC.Collect(), with the weak eventhandler the treenode never gets collected but i DOES get collected WIHTOUT the weak eventhandler.