A "bug" in my MSDN-TV spot on IDisposable
A customer (actually a “.NET Hacker”
from Sweden pointed
out a “bug” in my
MSDN-TV spot on IDisposable. At
minute 8:03 I said that ~Resource() overrides the Dispose method from Object. I
should have said that it overrides the Finalize() method from
Object.
That lead us to a discussion of what
“magic” the GC does with the finalize method. The GC detects that a particular instance
is of a class that overrides Finalize method when the instances of the type is
created. Then the GC sets a bit on the instances indicating that it should be
finalized. You can manually set
that bit with the GC.SuppressFinalizatio() and GC.ReRegisterForFinalization()
methods.