示例#1
0
    public MyClass BuildClass()
    {
        var dispObj = new DisposableObj();
        var retVal  = new MyClass(dispObj);

        return(retVal);
    }
示例#2
0
        /// <summary>
        /// Called from within the EE and releases all the cached data for the __ComObject.
        /// </summary>
        internal void ReleaseAllData()
        {
            // Synchronize access to the map.
            lock (this)
            {
                // If the map hasn't been allocated, then there is nothing to do.
                if (m_ObjectToDataMap != null)
                {
                    foreach (object o in m_ObjectToDataMap.Values)
                    {
                        // Note: the value could be an object[]
                        // We are fine for now as object[] doesn't implement IDisposable nor derive from __ComObject

                        // If the object implements IDisposable, then call Dispose on it.
                        if (o is IDisposable DisposableObj)
                        {
                            DisposableObj.Dispose();
                        }

                        // If the object is a derived from __ComObject, then call Marshal.ReleaseComObject on it.
                        if (o is __ComObject ComObj)
                        {
                            Marshal.ReleaseComObject(ComObj);
                        }
                    }

                    // Set the map to null to indicate it has been cleaned up.
                    m_ObjectToDataMap = null;
                }
            }
        }
示例#3
0
 protected virtual void Dispose(bool Disposing)
 {
     if (Disposing && Obj != null)
     {
         if (Obj is IDisposable DisposableObj)
         {
             DisposableObj.Dispose();
         }
     }
 }
示例#4
0
        private bool Delete(int Id)
        {
            object Obj = DomainObjects.Delete(Id);

            if (Obj is IDisposable DisposableObj)
            {
                DisposableObj.Dispose();
            }

            return(Obj != null);
        }
示例#5
0
        public void Delete(int Id)
        {
            if (Objs.TryRemove(Id, out object Obj))
            {
                if (Obj is IDisposable DisposableObj)
                {
                    DisposableObj.Dispose();
                }

                Ids.DeleteId(Id);
            }
        }
示例#6
0
文件: HDomain.cs 项目: ANR2ME/Ryujinx
        public void DeleteObject(int Id)
        {
            if (Objects.TryGetValue(Id, out object Obj))
            {
                if (Obj is IDisposable DisposableObj)
                {
                    DisposableObj.Dispose();
                }

                ObjIds.DeleteId(Id);
                Objects.Remove(Id);
            }
        }
示例#7
0
        public void Destroy()
        {
            lock (Table)
            {
                for (int Index = 0; Index < Size; Index++)
                {
                    KHandleEntry Entry = Table[Index];

                    if (Entry.Obj != null)
                    {
                        if (Entry.Obj is IDisposable DisposableObj)
                        {
                            DisposableObj.Dispose();
                        }

                        Entry.Obj  = null;
                        Entry.Next = NextFreeEntry;

                        NextFreeEntry = Entry;
                    }
                }
            }
        }