The first question would be, why would you want to prevent the garbage collection from running?
mikewinny wrote:
would that class be finalized before any of its references
I don't think so. The runtime doesn't guarantee when the objects will be collected and it doesn't provide any guarantees on the order the collection will occur.
mikewinny wrote:
would it be safe to assume all reference fields are still accessible at finalization time
If you are writing your own finalizer, you shouldn't be accessing other finalizable fields. Again, since the runtime doesn't guarantee any ordering, I would say that it isn't safe to make that assumption. The Environment.HasShutdownStarted property will tell you if your finalizer has started to run, but not much more than that. It is also only available in .NET 2.0 and later. Check out the latest updates to my article Implementing IDisposable and the Dispose Pattern Properly[^]. Hopefully, it will answer these questions in a little more detail. You may also find some additional answers here: SafeHandle and Constrained Execution Regions[^]