public static void WaitForPendingFinalizers() { while (GC.AnyPendingFinalizers()) { Thread.Sleep(10); } }