/// <summary> /// Dispose the instance /// </summary> /// <param name="keepAliveItem">don't dispose this item</param> public void Dispose(T keepAliveItem) { foreach (IDisposable item in this) { if (item.Equals(keepAliveItem)) { continue; } ICOMObjectDisposable disposeItem = item as ICOMObjectDisposable; if (null != disposeItem) { try { if (false == disposeItem.IsDisposed && false == disposeItem.IsDisposed) { disposeItem.Dispose(); } } catch { ; } } else { item.Dispose(); } } Clear(); }
/// <summary> /// Dispose the instance /// </summary> public void Dispose() { foreach (object item in this) { ICOMObjectDisposable disposeItem = item as ICOMObjectDisposable; if (null != disposeItem) { try { if (false == disposeItem.IsDisposed && false == disposeItem.IsDisposed) { disposeItem.Dispose(); } } catch { ; } } if (item is MarshalByRefObject) { try { Marshal.ReleaseComObject(item); } catch { ; } } } Clear(); }
/// <summary> /// Dispose the instance /// </summary> /// <param name="keepAliveItem">don't dispose this item</param> public void Dispose(T keepAliveItem) { foreach (T item in this) { ICOMObjectDisposable disposeItem = item as ICOMObjectDisposable; if (null != disposeItem && object.ReferenceEquals(item, keepAliveItem)) { if (false == disposeItem.IsDisposed && false == disposeItem.IsDisposed) { disposeItem.Dispose(); } } } _items = new T[0]; }
/// <summary> /// Dispose the instance /// </summary> public void Dispose() { foreach (object item in this) { ICOMObjectDisposable disposeItem = item as ICOMObjectDisposable; if (null != disposeItem) { if (false == disposeItem.IsDisposed && false == disposeItem.IsDisposed) { disposeItem.Dispose(); } } } _items = new T[0]; }