protected override void InternalDispose(bool disposing) { if (disposing) { if (this.RefreshTimer != null) { this.RefreshTimer.Dispose(false); } this.RefreshTimer = null; this.IsInitialized = false; } }
public void Initialize(TimeSpan refreshInterval, bool refreshNow = true) { if (this.IsInitialized) { return; } if (!string.IsNullOrEmpty(this.RefreshIntervalRegistryKey)) { int value = RegistryReader.Instance.GetValue <int>(Registry.LocalMachine, this.RefreshIntervalRegistryKey, "RefreshInterval", (int)ADObjectCache <TResult, TLoaderException> .DefaultRefreshInterval.TotalSeconds); refreshInterval = new TimeSpan(0, 0, value); } if (refreshNow) { this.Refresh(null); } this.RefreshTimer = new GuardedTimer(new TimerCallback(this.Refresh)); this.SetRefreshInterval(refreshInterval); this.IsInitialized = true; }