void MakeSureWeScrollToTheNewestHandShortlyIfNecessary() { if (NewestHandIsDisplayed) { _scrollToNewestHandTimer.Stop(); } else { _scrollToNewestHandTimer.Start(); } }
/// <inheritdoc /> protected override void Dispose(bool disposing) { if (disposing) { if (mDispatcherTimer.IsEnabled) { // Stop the timer as we are closing the Tab ( ICA html ) mDispatcherTimer.Stop(); } } base.Dispose(disposing); }
void OnTimerClicked(object sender, EventArgs e) { if (_timer != null) { _timer.Stop(); _timer = null; timerLabel.Text = "Stopped!"; return; } var now = DateTime.Now; var counter = 0; _timer = timerLabel.Dispatcher.CreateTimer(); _timer.Interval = TimeSpan.FromSeconds(3); _timer.IsRepeating = true; _timer.Start(); timerLabel.Text = "Started!"; _timer.Tick += (_, _) => { var later = DateTime.Now; counter++; timerLabel.Text = $"I am on a 3 second timer! {counter} ticks => {later - now}"; }; }
public OverlayBoardViewModel(IBoardViewModel boardViewModel, IDispatcherTimer dispatcherTimer) { _dispatcherTimer = dispatcherTimer; _boardViewModel = boardViewModel; _dispatcherTimer.Tick += (s, e) => { _dispatcherTimer.Stop(); BoardViewModel.Visible = false; }; }
public OverlayHoleCardsViewModel(IHoleCardsViewModel holeCardsViewModel, IDispatcherTimer dispatcherTimer) { _dispatcherTimer = dispatcherTimer; _holeCardsViewModel = holeCardsViewModel; _dispatcherTimer.Tick += (s, e) => { _dispatcherTimer.Stop(); HoleCardsViewModel.Visible = false; }; }
private void UpdateTimeout() { TimeSpan timeout = TimeSpan.Zero; switch (mState) { case ProtocolState.Idle: timeout = TimeSpan.FromSeconds(5); break; case ProtocolState.InitSent: timeout = TimeSpan.FromSeconds(5); break; } mProtocolTimeout.Stop(); if (timeout != TimeSpan.Zero) { mProtocolTimeout.Interval = timeout; mProtocolTimeout.Start(); } }
void OnTick(object sender, EventArgs e) { DateTime now = DateTime.Now; #if DEBUG var moqArgs = e as MoqTimerEventArgs; if (moqArgs == null) //ie not running a test { System.Diagnostics.Debug.WriteLine("tick at:{0} interval had been:{1}", now, _timer.Interval); } else { now = moqArgs.Now; } #endif TimeSpan nowTime = now.TimeOfDay.Add(_adjustIntoFuture); //if (_participants.Count == 0) { _timer.Stop(); return; } do { if (OnAgeIncrement == null) { _nextIndex++; } else { IBirthday p = _participants[_nextIndex].Value; p.AgeDays = (now - p.DateTimeBirth).Days; AgeIncrementingEventArgs arg = new AgeIncrementingEventArgs(p); OnAgeIncrement(this, arg); if (arg.Remove) { _participants.RemoveAt(_nextIndex); if (_participants.Count == 0) { _timer.Stop(); return; } } else { _nextIndex++; } } if (_nextIndex >= _participants.Count) { _nextIndex = 0; break; } } while(_participants[_nextIndex].Key <= nowTime); nowTime = DateTime.Now.TimeOfDay; #if DEBUG if (moqArgs != null) { nowTime = moqArgs.Now.TimeOfDay; } else { System.Diagnostics.Debug.WriteLine("next interval set at:{0}", _participants[_nextIndex].Key - nowTime); } #endif TimeSpan nextInterval = _participants[_nextIndex].Key - nowTime; if (nextInterval.Ticks < 0) { nextInterval += TimeSpan.FromDays(1); } _timer.Interval = nextInterval; }
/// <summary> /// Necessary to prevent memory leaks /// http://geekswithblogs.net/dotnetrodent/archive/2009/11/05/136015.aspx /// </summary> public void Dispose() { _dispatcherTimer.Stop(); }
public void Stop() { _dispatcherTimer.Stop(); }
public void Dispose() { _watchTableTimer.Stop(); _waitThenTryToFindTableAgainTimer.Stop(); _tableOverlayWindow.Dispose(); }
protected override void OnDisappearing() { _timer.Stop(); _timer = null; }
protected void StopClock() { _timer.Stop(); }