调用GC.SupressFinalize而不会破坏所有对象? [英] calling GC.SupressFinalize with out destroying all objects?

查看:94
本文介绍了调用GC.SupressFinalize而不会破坏所有对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要在一个类中创建多个对象的实例,如果我只处理一个对象并调用GC.SupressFinalize(this),会发生什么.只想知道对方是否被处置.请让我知道是否不清楚.

What happens if i am creating instance of more than one object in a class, if i dispose only one object and call the GC.SupressFinalize(this). Just want to know whether the other gets disposed or not. Please let me know if am not clear.

推荐答案

GC.SupressFinalize处理您正在使用的特定实例.它与同一类的另一个实例没有关系.它用于防止垃圾收集尝试两次收集此类实例的垃圾.底线-在某些情况下这是一个有用的功能,但对同一个类的其他实例没有影响.

参考:

http://msdn.microsoft.com/en-us/library/system.gc.抑制finalize.aspx [ ^ ]
GC.SupressFinalize handles the specific instance you are working with. It has not relation to another instance of the same class. It is used to prevent the Garbage Collection from trying to collect the garbage of this class instance twice. Bottom line - it is a useful feature in some circumstances but it has no bearing on other instances of the same class.

Reference:

http://msdn.microsoft.com/en-us/library/system.gc.suppressfinalize.aspx[^]


这篇关于调用GC.SupressFinalize而不会破坏所有对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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