Windows.Forms关闭和处理 [英] Windows.Forms Close and Dispose

查看:84
本文介绍了Windows.Forms关闭和处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据规范,如果显示模态(ShowDialog),则在调用Close后不会释放Form对象。在.NET Compact Framework 2.0应用程序(Windows Mobile 6)中,我们会遇到一些表单(或单个控件),而没有
显式调用他们或他们父母的Dispose方法。这些控件在我们创建一次的表单上,当用户选择一个项目然后用户关闭它们时使用ShowDialog显示(Close()方法)。原因不明的Dispose-s仅在字段上发生,不能再生成


.NET Compact Framework的模态表单在关闭和处理方面的表现是否不同?

解决方案

可能
Dispose 由"finaliser"调用,当垃圾收集器检测到未引用该对象组时会发生这种情况。


According to specs, Form objects does not get disposed after calling Close, if they were shown modal (ShowDialog). In a .NET Compact Framework 2.0 application (Windows Mobile 6) we encounter some forms (or individual controls) being disposed without explicitly calling their or their parents' Dispose method. These controls are on forms we create once and shown with ShowDialog when the user selects an item and then the user closes them (Close() method). The unexplained Dispose-s occur only on field, cannot be reproduced.

Is NET Compact Framework's modal Forms behaves differently regarding Close and Dispose?

解决方案

Maybe Dispose is called by "finaliser", which happens when Garbage Collector detects that the group of objects is not referenced.


这篇关于Windows.Forms关闭和处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆