Example #1
0
        private static void CreateAndCheckInheritedObjects(out WeakReference parentWRef, out WeakReference childWRef)
        {
            var parent = new Inherit3Parent();
            var child  = new Inherit3Child(parent);

            parentWRef = new WeakReference(parent);
            childWRef  = new WeakReference(child);

            Console.WriteLine($"Parent [{parent.ToString()}] has {Efl.Eo.Globals.efl_ref_count(parent.NativeHandle)} refs");
            Console.WriteLine($"Child [{child.ToString()}] has {Efl.Eo.Globals.efl_ref_count(child.NativeHandle)} refs");

            child = null;

            System.GC.Collect(System.GC.MaxGeneration, GCCollectionMode.Forced, true, true);
            System.GC.WaitForPendingFinalizers();
            Efl.App.AppMain.Iterate();

            child = (Inherit3Child)childWRef.Target;

            Test.AssertNotNull(parent);
            Test.AssertNotNull(child);
            Test.AssertEquals(false, parent.disposed);
            Test.AssertEquals(false, parent.childDisposed);

            Console.WriteLine($"Parent [{parent.ToString()}] has {Efl.Eo.Globals.efl_ref_count(parent.NativeHandle)} refs");
            Console.WriteLine($"Child [{child.ToString()}] has {Efl.Eo.Globals.efl_ref_count(child.NativeHandle)} refs");

            parent = null;
            child  = null;
        }
Example #2
0
        private static void CreateAndCheckInheritedObjects(out WeakReference parentWRef, out WeakReference childWRef)
        {
            var parent = new Inherit3Parent();
            var child  = new Inherit3Child(parent);

            parentWRef = new WeakReference(parent);
            childWRef  = new WeakReference(child);

            child = null;

            System.GC.Collect(System.GC.MaxGeneration, GCCollectionMode.Forced, true, true);
            System.GC.WaitForPendingFinalizers();
            Efl.App.AppMain.Iterate();

            child = (Inherit3Child)childWRef.Target;

            Test.AssertNotNull(parent);
            Test.AssertNotNull(child);
            Test.AssertEquals(false, parent.disposed);
            Test.AssertEquals(false, parent.childDisposed);

            parent = null;
            child  = null;
        }