/// <summary> /// Raised when the client disconnects from Discord. /// <para> /// Stops the <see cref="TimerService"/> and logs that the client has disconnected along with exception information. /// </para> /// </summary> /// <param name="e">The exception thrown on disconnect.</param> /// <returns>No object or value is returned by this method when it completes.</returns> private Task DisconnectedEventHandler(Exception e) { Console.WriteLine( $"\n{DateTime.Now}\nCLIENT DISCONNECTED\nMessage: {e.Message}\n---STACK TRACE---\n{e.StackTrace}\n\n"); _timer.Stop(); return(Task.CompletedTask); }
public async void PausePomodoro() { TimerService.Stop(); PomodoroStatus = PomodoroTimerState.Paused(PomodoroSettings.PomodoroDuration, PomodoroStatus.RemainingTime); await StorageService.SaveAppState(PomodoroStatus); PomodoroTimerStateChangedEvent?.Invoke(this, new PomodoroTimerStateChangedEventArgs(PomodoroStatus)); LogState("PausePomodoro"); }
public LampStateMachine(IMessageService messageService, ITimeService timeService = null, LampState initialState = LampState.Off, ITimerService timer = null) : base(initialState) { this.timeService = timeService ?? new TimeService(); this.timer = timer ?? new TimerService(); timer.Elapsed += (s, a) => this.Fire(LampTrigger.ElapsedTime); this.Configure(LampState.Off) // .Permit(LampTrigger.PushUp, LampState.On) .PermitIf(LampTrigger.PushUp, LampState.On, () => IsOverTime, $"Limit > {TimeLimit}") .IgnoreIf(LampTrigger.PushUp, () => !IsOverTime, $"Limit <= {TimeLimit}") .Ignore(LampTrigger.PushDown) .OnEntry(() => messageService.Send("Dziękujemy za wyłączenie światła"), nameof(messageService.Send)); this.Configure(LampState.On) .OnEntry(() => messageService.Send("Pamiętaj o wyłączeniu światła!"), nameof(messageService.Send)) .OnEntry(() => timer.Start(), "Start timer") .Permit(LampTrigger.PushDown, LampState.Off) .PermitIf(LampTrigger.PushUp, LampState.Red, () => !IsOverLimit) .PermitIf(LampTrigger.PushUp, LampState.Off, () => IsOverLimit) .Permit(LampTrigger.ElapsedTime, LampState.Off) .OnExit(() => timer.Stop()); this.Configure(LampState.Red) .OnEntry(() => redCounter++) .Permit(LampTrigger.PushUp, LampState.On) .Permit(LampTrigger.PushDown, LampState.Off); this.OnTransitioned(t => Console.WriteLine($"{t.Source} -> {t.Destination}")); this.timer = timer; }
private static void WriteTicks(int timer, int tickSoFar, int totalTicks, ITimerService timerService) { Console.WriteLine("Timer {0}: {1}/{2}", timer, tickSoFar, totalTicks); if (tickSoFar >= totalTicks) { timerService.Stop(timer); } }
public void Stop() { mExerciseTrackerService.ExerciseFinished(mExercise); mTimerService.Stop(); SignalActiveSubExerciseChanged(mExercise.CurrentSubExercise, SubExercise.Undefined); mExercise.Reset(); SignalExerciseChanged(); ChangeState(ExerciseServiceState.Stopped); }
public void Dispose() { _withdrawTimer.Stop(); _withdrawTimer.Dispose(); _logTimer.Stop(); _logTimer.Dispose(); parking.Vehicles = new List <Vehicle>(); parking.Balance = 0; }
/// <summary> /// 計測を一時停止する /// </summary> public void Pause() { if (Status == StopwatchStatus.Running) { _timerService.Stop(); _storedTime += _timeService.Now - _beginDateTime; ElapsedTime = _storedTime; Status = StopwatchStatus.Paused; } else { throw new InvalidOperationException($"Stopwatch status is {Status}."); } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (!disposing) { return; } if (-1 == timerId) { return; } timerService.Stop(timerId); timerId = -1; }
public void StopPomodoro() { TimerService.Stop(); PomodoroStatus = new PomdoroStatus() { RemainingTime = TimeSpan.Zero, RunTime = TimeSpan.Zero, StartTime = DateTime.Now, PomodoroState = PomodoroState.Ready, TimerState = TimerState.Stoped, }; StorageService.SaveAppState(PomodoroStatus); PomodoroTimerStatusChangedEvent?.Invoke(this, new PomodoroTimerStatusChangedEventArgs(PomodoroStatus)); }
public void OnGameModeInit(ITimerService timerService) { _stopwatch1.Start(); _stopwatch2.Start(); TimerReference timer = null; timer = timerService.Start(_ => { if (++_readonlyTicks == 3) { Console.WriteLine("Stop timer"); timerService.Stop(timer); } Console.WriteLine($"Manual timer {_stopwatch2.Elapsed}"); _stopwatch2.Restart(); }, TimeSpan.FromSeconds(0.1)); }
public async Task ReloadAsync() { try { await _data.DeserialiseConfig(true); _timer.Stop(); _timer.Start(); await ReplyAsync("```Successfully reloaded settings.```"); await _data.ChannelLog($"{Context.User} successfully reloaded the settings."); } catch (InvalidOperationException e) { await _data.ChannelLog($"{Context.User} failed to reload the settings.", e.Message); await Context.Channel.SendMessageAsync( $"An error occurred reloading the config. Reverting to the previous config. ```{e.Message}```"); } await DataBaseUtil.AddCommandAsync("Reload", Context); }
private void Stop() { _timerService.Stop(); }
private static void WriteTicks(int timer, int tickSoFar, int totalTicks, ITimerService timerService) { Console.WriteLine("Timer {0}: {1}/{2}", timer, tickSoFar, totalTicks); if (tickSoFar >= totalTicks) timerService.Stop(timer); }
public override Task Destroy() { timerService.Stop(); return Task.CompletedTask; }
private void Stop() { _timerService.Stop(); IsRunning = _timerService.IsRunning(); }
public void Stop() { _timerService.Stop(); }
public override void Stop() { _timerService.Stop(); _cyclicRunner.Stop(); }
public void Pause() { _timerService.Stop(); _pauseResumeNodes.ForEach(n => n.Stop()); }
protected override Task OnStop(IMessageSession messageSession) { return(_timerService.Stop()); }