private void InitDisposableMembers() { bool dispose = true; try { _cacheMemoryMonitor = new CacheMemoryMonitor(_memoryCache, _configCacheMemoryLimitMegabytes); _timer = new Timer(new TimerCallback(CacheManagerTimerCallback), null, _configPollingInterval, _configPollingInterval); dispose = false; } finally { if (dispose) { Dispose(); } } }
private void InitDisposableMembers() { bool flag = true; try { this._cacheMemoryMonitor = new CacheMemoryMonitor(this._memoryCache, this._configCacheMemoryLimitMegabytes); this._timer = new Timer(new TimerCallback(this.CacheManagerTimerCallback), null, this._configPollingInterval, this._configPollingInterval); flag = false; } finally { if (flag) { this.Dispose(); } } }
private void InitDisposableMembers() { bool dispose = true; try { _cacheMemoryMonitor = new CacheMemoryMonitor(_memoryCache, _configCacheMemoryLimitMegabytes); Timer timer; // Don't capture the current ExecutionContext and its AsyncLocals onto the timer causing them to live forever bool restoreFlow = false; try { if (!ExecutionContext.IsFlowSuppressed()) { ExecutionContext.SuppressFlow(); restoreFlow = true; } timer = new Timer(new TimerCallback(CacheManagerTimerCallback), null, _configPollingInterval, _configPollingInterval); } finally { // Restore the current ExecutionContext if (restoreFlow) { ExecutionContext.RestoreFlow(); } } _timerHandleRef = new GCHandleRef <Timer>(timer); dispose = false; } finally { if (dispose) { Dispose(); } } }