internal MemoryCacheStore(MemoryCache cache, PerfCounters perfCounters) { _cache = cache; _perfCounters = perfCounters; _entries = new Hashtable(new MemoryCacheEqualityComparer()); _entriesLock = new Object(); _expires = new CacheExpires(this); _usage = new CacheUsage(this); InitDisposableMembers(); }
private void InitDisposableMembers(NameValueCollection config) { bool flag = true; try { try { this._perfCounters = new PerfCounters(this._name); } catch { } for (int i = 0; i < this._stores.Length; i++) { this._stores[i] = new MemoryCacheStore(this, this._perfCounters); } this._stats = new MemoryCacheStatistics(this, config); AppDomain domain = Thread.GetDomain(); EventHandler handler = new EventHandler(this.OnAppDomainUnload); domain.DomainUnload += handler; this._onAppDomainUnload = handler; UnhandledExceptionEventHandler handler2 = new UnhandledExceptionEventHandler(this.OnUnhandledException); domain.UnhandledException += handler2; this._onUnhandledException = handler2; flag = false; } finally { if (flag) { this.Dispose(); } } }
private void InitDisposableMembers(NameValueCollection config) { bool dispose = true; try { try { _perfCounters = new PerfCounters(_name); } catch { // ignore exceptions from perf counters } for (int i = 0; i < _stores.Length; i++) { _stores[i] = new MemoryCacheStore(this, _perfCounters); } _stats = new MemoryCacheStatistics(this, config); AppDomain appDomain = Thread.GetDomain(); EventHandler onAppDomainUnload = new EventHandler(OnAppDomainUnload); appDomain.DomainUnload += onAppDomainUnload; _onAppDomainUnload = onAppDomainUnload; UnhandledExceptionEventHandler onUnhandledException = new UnhandledExceptionEventHandler(OnUnhandledException); appDomain.UnhandledException += onUnhandledException; _onUnhandledException = onUnhandledException; dispose = false; } finally { if (dispose) { Dispose(); } } }