private void UpdateTimer() { lock (_syncObj) { if (!_checkForExpiredItems) { if (_expirationTimer != null) { _expirationTimer.Dispose(); _expirationTimer = null; } } else { var timeSpan = _expirationTimerInterval; if (_expirationTimer is null) { // Always create timers with infinite, then update them later so we always have a populated timer field _expirationTimer = new Catel.Threading.Timer(OnTimerElapsed, null, Timeout.Infinite, Timeout.Infinite); } _expirationTimer.Change(timeSpan, timeSpan); } } }
/// <summary> /// Initializes a new instance of the <see cref="CachedRepositoryBase{TModel}" /> class. /// </summary> protected CachedRepositoryBase() { Expiration = new TimeSpan(); DataLoadedTimestamp = DateTime.MinValue; _timer = new Catel.Threading.Timer(OnTimerElapsed, null, 1000, 1000); }
private void UpdateTimer() { lock (_syncObj) { if (!_checkForExpiredItems) { if (_expirationTimer != null) { _expirationTimer.Dispose(); _expirationTimer = null; } } else { var timeSpan = _expirationTimerInterval; if (_expirationTimer == null) { _expirationTimer = new Catel.Threading.Timer(OnTimerElapsed, null, timeSpan, timeSpan); } else { _expirationTimer.Change(timeSpan, timeSpan); } } } }
/// <summary> /// Initializes a new instance of the <see cref="BatchLogListenerBase" /> class. /// </summary> /// <param name="maxBatchCount">The maximum batch count.</param> public BatchLogListenerBase(int maxBatchCount = 100) { MaximumBatchCount = maxBatchCount; var interval = TimeSpan.FromSeconds(5); _timer = new Catel.Threading.Timer(OnTimerTick, null, interval, interval); }
/// <summary> /// Initializes a new instance of the <see cref="BatchLogListenerBase" /> class. /// </summary> /// <param name="interval">The interval between the auto-flushes.</param> /// <param name="maxBatchCount">The maximum batch count.</param> public BatchLogListenerBase(TimeSpan interval, int maxBatchCount = 100) { _timer = new Timer(OnTimerTick); MaximumBatchCount = maxBatchCount; Interval = interval; }
/// <summary> /// Initializes a new instance of the <see cref="CachedRepositoryBase{TModel}" /> class. /// </summary> protected CachedRepositoryBase() { Expiration = new TimeSpan(); DataLoadedTimestamp = DateTime.MinValue; var timeout = TimeSpan.FromSeconds(1); _timer = new Catel.Threading.Timer(OnTimerElapsed, null, timeout, timeout); }
/// <summary> /// Initializes a new instance of the <see cref="ViewLoadManager"/> class. /// </summary> public ViewLoadManager() { _cleanUpTimer = new Threading.Timer(x => CleanUp(), null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30)); }