Where to dispose resources in a System.Windows.Form-derived class?

别说谁变了你拦得住时间么 提交于 2019-12-05 08:29:18

You can move the Dispose() method from the Designer.cs file to your source code file. And alter it to add dispose calls for any disposable members in your form class. This is one of the few cases where it is okay to edit the designer file, you only need to stay away from the code that inside the #region marked "Windows Form Designer generated code".

I've often wondered about this though I never actually ran into an issue with it. You can use the Disposed event, although there might be a better way to hook into Dispose that I missed.

Form and Control provide a "Disposed" event that may be used to dispose any resources they use.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!