Does garbage collector call Dispose()? [duplicate]

荒凉一梦 提交于 2019-11-26 22:31:47
Eloff

The GC does not call Dispose, it calls your finalizer (which you should make call Dispose(false)).

Please look at the related posts on the side or look up the C# best practices for the Dispose pattern (The docs on IDisposable explain it quite well IIRC.)

Dave Black

Short answer is "no". More detailed answers can be found on my replies to "Is it bad practice to depend on the .NET Garbage Collector" and "What happens if I don't call Dispose()"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!