在线用户    站点地图 技术论坛 文档中心 站点导航 资源下载 语言参考 教程专题 站点统计 业务项目 使用帮助
您的位置
MSDN参考新加了CSS2参考,全中文,制作精良。245k下载。           新加了sxf_sxf推荐的"动态网页专家指导" 下载!          新加了lsg2002lsg推荐的"ASP.NET高级编程(PDF)" 下载!          新加了DHTML代码预览!!,功能强大哦!欢迎试用          新加了网友lincong为大家提供的SQL Server 2000 程序员指南,有点大,但同时也就说明内容全咯!           新加了网友ibra为大家提供的北大的JAVA课件,很适合初学者入门           新加了一个java的连接缓冲池代码示例           新加了人月神话电子版下载!软件工程巨著哦~~           更新了评分标准,引入了“专家分”概念,相信可以更好的激励大家的学习!详情请看“使用帮助”           新加了由网友GGG提供的“IIS超级管理手册”,值得一看哦!(虽然我没看过 :P )           新加了“英雄榜”,欢迎测试!           “无组件上传·从原理剖析到实践”已经全部完成,源码全部开放,有兴趣的朋友请到文档中心一探究竟。  您的位置  首页>技术论坛>C#>F0107928 在同一窗口中打开页面中的链接 在新窗口中打开页面中的链接 将ASPCHINA设为首页 将ASPCHINA加入书签    
 LOGIN HERE
用户:
密码: 忘记密码
记住密码 用户注册 游客进入

论坛首页
|--web开发
   |--ASP
   |--JSP
   |--ASP.net
   |--DHTML
   |--RUBY
|--软件开发
   |--C++
      |--Code here
   |--JAVA
   |--VB
   |--Delphi
   |--XML
|--.net技术
   |--C#
   |--VB.net
|--Yup开发组
|--站务&投诉
   |--站长专区
|--硬件&网络
|--休息室
|--数据库技术
 进入精华区 我要发言



 Dispose是做什么用的?back to C# forum  
作者:goldentime,6级分数:10
日期:2004/2/20 21:21:00类别:C#, 技术问题
回复:4次浏览:1045次
状态:已结贴 [miles(10)]

C#应用程序项目里面窗体代码中
有一个protected override void Dispose( bool disposing )方法
这个方法是做什么用的?
什么时候会执行到?

reply[F0107928]
 



 
 re [1] Dispose是做什么用的?C# forum  
- miles04-02-23 09:38  

dispose的字面意思是“处理”,这里就是当component不再使用时候,调用他释放资源。比如,当你不用一个Form,就可以调用他的dispose方法,这时候他会接连调用子元素的dispose方法,释放资源。

reply[F0108136]
 



 
 re [2] Dispose是做什么用的?C# forum  
- lightsword_zt04-03-11 15:39  

是析构函数.

reply[F0110979]
 



 
 re [3] Dispose是做什么用的?C# forum  
- miles04-03-11 15:59  

不是的。finalize才差不多。

public void dispose()

Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.
The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to pack or show. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifcations between those actions).

reply[F0110983]
 



 
 re [3] Dispose是做什么用的?C# forum  
- miles04-03-11 16:05  

sorry, 上面是java的api doc

.net的:

Finalize

This method is automatically called after an object becomes inaccessible, unless the object has been exempted from finalization by a call to SuppressFinalize. During shutdown of an application domain, Finalize is automatically called on objects that are not exempt from finalization, even those that are still accessible. Finalize is automatically called only once on a given instance, unless the object is re-registered using a mechanism such as ReRegisterForFinalize and GC.SuppressFinalize has not been subsequently called.

Dispose
Calling Dispose allows the resources used by the Component to be reallocated for other purposes. For more information about Dispose, see Cleaning Up Unmanaged Resources.

和java没什么区别,呵呵。

reply[F0110985]
 



您的位置
  (c)2000-2019 Yup Studio, all rights reserved.  
78.125