VS 2010 Beta《法典》分析向我建议,总会处理按行业分类的按行业分类服务客户和数据背景。 这是否可取? 我假定,不管最终会发生什么情况。 究竟是含蓄地这样做的利弊是什么?
我是否总是暗含地放弃全球合作框架服务客户和数据背景?
原标题:Should I always implicitly Dispose WCF Service Clients and Data Contexts?
最佳回答
有了<>任何<<>>>条/>条码<>可支配条码>,你的任务是确保及时清理,关闭公开资源等(连接等)。 简言之,是。 只有在GC kicks(时间可能很长)的情况下,才会发生最终用途,并且不允许最佳的集合使用等。
但请注意,世界碳基金有代谢历史:<代码>Dispose() 执行,justusing
a bit at-n-miss (You can loss the actual exception). 当然,也建议通过合成方法使用周转基金,这再次使得难以使用<代码>using;你经常需要在国际交易日志的电话中明确提及并打电话<代码>Dispose(。
你们的评论;几个例子:
SqlConnection
: if you leave this hanging around (open) you prevent it reusing the connection from a pool; you can ultimately saturate the available connections this way, breaking your app- GDI: IIRC, VS2005 itself (or 2003?) had a bug where an undisposed GDI object; GDI objects don t take much memory, so it didn t trigger GC, but it ran out of available handles and broke (this is a common bug in user code too, but more famous in an IDE)
- fail to dispose something like a
FileStream
: you ve blocked your file system - fail to dispose a
TransactionScope
and you ve caused db (etc) blocking
问题回答
暂无回答
相关问题
热门标签
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding