Esempio n. 1
0
        public static void TraceLiveObjects()
        {
            var array = LiveObjects.ToArray();

            foreach (var kv in array)
            {
                kv.Value.Trace(null, "? ");
            }
        }
Esempio n. 2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_dispose)
            {
                return;
            }

            //#if DEBUG
            //            Trace("~disposing: " + disposing + " duration: " + Duration.Milliseconds);
            //#endif
            if (!IsDisposed)
            {
                if (disposing)
                {
                    // dispose managed state (managed objects).
                }

                // free unmanaged resources (unmanaged objects) and override a finalizer below.
                // set large fields to null.

                var obj = Interlocked.Exchange(ref _object, null);
                if (obj != null)
                {
#if DEBUG
                    //var typeName = GetType().FullName;
                    //if (typeName.IndexOf("textlayout", StringComparison.OrdinalIgnoreCase) >= 0 ||
                    //    typeName.IndexOf("textformat", StringComparison.OrdinalIgnoreCase) >= 0)
                    //    return;

                    var count = Marshal.ReleaseComObject(obj);
                    Trace("disposing: " + disposing + " count: " + count, "~");
                    LiveObjects.TryRemove(Id, out _);
#else
                    Marshal.ReleaseComObject(obj);
#endif
                }
            }
        }