Too Long; Didn't Read
In this post, we will see an example of a scenario where we may want to extend the lifetime of an object. We will look at how we can accomplish this in two ways — one is writing an API ourselves (in the spirit of learning by doing) and other is to use existing API in.NET. The Lifeline.KeepAlive() method has absolutely no code in it. The key feature of this method is the attribute on the method [MethodImpl(MethodImplOptions.NoInlining) This guarantees the JIT will never try to inline this method.