c# - .NET 紧凑框架中清理资源的最佳方法

标签 c# compact-framework

我在 .Net 紧凑框架中的解决方案上有多种形式,使用 Implementing the Singleton Pattern in C# 中描述的所有单例模式。 (第四版)。有些表格很少使用,而另一些表格则必须长期维护。由于我有一些内存/处理器限制问题,我需要知道使用 form.Dispose() 或其他方法来清理资源的最佳方法是什么。

最佳答案

你写的是“其他的我必须维护它很长时间”。我假设您需要访问该表单上的资源。这真的有必要吗?表单基本上是用作输入元素的占位符并显示数据,而不是用作变量容器。

此外,您不需要在表单上显式调用 Dispose(),垃圾收集器本身会执行 Show() 操作:

http://msdn.microsoft.com/en-us/library/aw58wzka.aspx

Dispose will be called automatically if the form is shown using the Show method. If another method such as ShowDialog is used, or the form is never shown at all, you must call Dispose yourself within your application.

关于c# - .NET 紧凑框架中清理资源的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4993797/

相关文章:

c# - 使用存储过程最优雅的方法是什么?

c# - 将驻留字符串转换为对象后为假

c# - HtmlAgilityPack WebGet.Load 给出错误 "Object reference not set to an instance of an object"

紧凑 .net 和常规 .net 之间的 C# 序列化/反序列化

.net - 是否有可靠的方法使 Compact Framework 和桌面项目与 Visual Studio 2008 保持同步?

c# - 如何从 URL 获取图像到 pictureBox? ( Windows Mobile )

c# - 如何在运行时优化 lambda?

用于信息或导入外部函数的 C# 属性?

c# - 在 Visual Studio 中,如何从项目资源文件夹加载 .png 图像?

c# - 检测并防止/延迟Windows移动电源关闭