private void CallMethod(LifetimeTester value) { var label = value.Label; SleepAndCollect($" after start CallMethod({label})"); value.Reference(); NativeCode(value.Label, new WeakReference(value)); SleepAndCollect($" after end CallMethod({label})"); }
private void DoWork() { global = new LifetimeTester("GLOBAL", Log); instance = new LifetimeTester("CLASS ", Log); var localWithNothing = new LifetimeTester("LOCAL ", Log); var localWithReference = new LifetimeTester("REF ", Log); SleepAndCollect("after construction"); CallMethod(localWithNothing); SleepAndCollect("after localWithNothing"); CallMethod(localWithReference); SleepAndCollect("after localWithReference"); var testing = localWithReference.ToString(); SleepAndCollect("reference: " + testing); SleepAndCollect("end"); }