コード例 #1
0
        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})");
        }
コード例 #2
0
        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");
        }