I have been thinking about the notion of “Weak Delegate” for a long time. For those who don't want to remove (-=) the delegate everytime, here is a thorough description about the potential memory leak problem and the solution and sample code by Greg Schechter. And here is a generic version by Ian Griffiths.
Be advised: Weak Delegate or not, A Memory Leak is a memory leak. You should ALWAYS remember to remove the eventhandler once the listener is out of scope.
打印 | 张贴于 2004-09-22 03:59:00 | Tag:.NET
留言反馈