[英]How does the CLR find the classes which implement IDisposable?
I need some clarification on… 我需要澄清......
… how the CLR — more specifically, the garbage collector — finds the classes which implement the IDisposable
interface; ... CLR - 更具体地说,垃圾收集器 - 如何找到实现IDisposable
接口的类; and 和
… how it calls the Dispose
method (of all classes which implement the IDisposable
interface) to free up memory? ...它如何调用Dispose
方法(实现IDisposable
接口的所有类)来释放内存?
The CLR does not call Dispose(), this is up to user code to call either directly or through the use of the using
statement. CLR不调用Dispose(),这取决于用户代码直接调用还是通过使用using
语句调用。 The CLR will however call finalizers , although this is not gauranteed. 然而,CLR将调用终结器 ,尽管这不是gauranteed。
Dispose
is not called automatically. 不会自动调用Dispose
。 The compiler generates calls to Dispose
when you write using
, or call Dispose
directly. 编译器生成调用Dispose
,当你写using
,或致电Dispose
直接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.