Skip to content

Instantly share code, notes, and snippets.

@Porges
Created May 2, 2012 23:38
Show Gist options
  • Save Porges/2581933 to your computer and use it in GitHub Desktop.
Save Porges/2581933 to your computer and use it in GitHub Desktop.
Objects can be collected while their instance methods are still executing
using System;
static class Program
{
public static void Main()
{
new Slow().Go();
}
}
class Slow
{
~Slow()
{
Console.WriteLine("collected");
}
public void Go()
{
Console.WriteLine("start method");
GC.Collect();
GC.WaitForPendingFinalizers();
Console.WriteLine("end method");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment