In this question @Jon skeet referenced this old blog post by the authority Chris Brumme.
I was wondering, do I need to follow all calls to GC.SuppressFinalize(this) with a GC.KeepAlive(this) to avoid weird race conditions where a finalizer can be invoked during the time a disposer is running in heavily multithreaded applications?
If so, can you come up with a sample program that exposes this bug?
No.
GC.KeepAlivedoesn’t actually do anything; its purpose is to ‘fool’ the runtime into preventing a specific object from being garbage collected between the start of the method and the call toGC.KeepAlive.Any method call will keep an object alive in this way: you could pass it to
Console.WriteLine, callToString, or even…GC.SuppressFinalize.(Or as MSDN puts it: