【发布时间】:2012-01-04 21:06:23
【问题描述】:
默认情况下,当您创建一个 Win-Form 应用程序时,这是由 Visual Studio 生成的用于处理 Form 的代码。
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
这够了吗?或者我应该取消注册所有事件,以便控件准备好被垃圾收集器收集?
if (disposing && (components != null))
{
myButton.OnClick-= MyFunction; //may be here!!
// ... all events used
components.Dispose();
}
【问题讨论】:
标签: c# winforms memory-management memory-leaks