Example #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (handle != IntPtr.Zero)
            {
                if (disposing)
                {
                    ReleaseManagedRef();
                }
                else
                {
                    NSObject_Disposer.Add(this);
                }
            }
            if (super != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(super);
                super = IntPtr.Zero;
            }
        }
Example #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (handle != IntPtr.Zero)
            {
                if (disposing)
                {
                    ReleaseManagedRef();
                }
                else
                {
                    NSObject_Disposer.Add(this);
                }
            }
        }
Example #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (handle != NativeHandle.Zero)
            {
                if (disposing)
                {
                    ReleaseManagedRef();
                }
                else
                {
#if NET
                    // By adding an external reference to the object from finalizer we will
                    // resurrect it. Since Runtime class tracks the NSObject instances with
                    // GCHandle(..., WeakTrackResurrection) we need to make sure it's aware
                    // that the object was finalized.
                    //
                    // On CoreCLR the non-tracked objects don't get a callback from the
                    // garbage collector when they enter the finalization queue but the
                    // information is necessary for Runtime.TryGetNSObject to work correctly.
                    // Since we are on the finalizer thread now we can just set the flag
                    // directly here.
                    actual_flags |= Flags.InFinalizerQueue;
#endif

                    NSObject_Disposer.Add(this);
                }
            }
            else
            {
                FreeData();
            }
        }