关于IDispose的问题

关于IDispose的问题

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

问题描述

使用using构造,退出范围调用dispose对所述对象。但是

在连接池场景中会发生什么?运行时是否足够智能

意识到正在使用对象池,因此它不会调用dispose和

而是标记对象类似于close()所做的汇集在

效果。或者它真的继续并关闭对象?如果是的话,

那么它是不是在规避对象池?有人知道吗?


我问,因为我经常使用using构造而不是调用close,但

我想知道如果我将费用引入等式中处置不是像我想象的那样有效地行事。


??


-

问候,

Alvin Bruney [ASP.NET MVP]

得到花絮?在此处获取...

解决方案





实现者来编写一个与池系统一起正常工作的Dispose方法。您将需要分析相关课程的行为。







你确定*使用上述模式实际上忽略了

连接池?不要以为在MySQLConnection实例与

数据库的实际连接之间存在直接关联




-

Jon Skeet - < sk *** @ pobox.com>


如果回复群组,请不要给我发邮件

with the using construct, exit from scope calls dispose on said object. But
what happens in a connection pooling scenario? Is the run-time smart enough
to realize that Object Pooling is being used so it will not call dispose and
instead flag the object similar to what close() does when pooling is in
effect. Or does it really go ahead and shut down the object? If it does,
then isn''t it circumventing the object pooling? Does anybody know?

I ask because I often use the using construct instead of calling close, but
I wonder if I am introducing expense into the equation if the dispose is not
behaving efficiently like I assumed.

??

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b

解决方案




implementer to write a Dispose method that works properly with the pooling system. You
will have to analyze the behaviour of the class in question.






Are you *sure* that using the above pattern is actually ignoring
connection pooling? Don''t assume that there''s a direct correlation
between MySQLConnection instances and actual connections to the
database.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于关于IDispose的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 17:13