public OperationViewModel(IScheduler scheduler) { dialogService = Locator.CurrentMutable.GetService <IDialogService>(); stopWatch = new Stopwatch(); Start = ReactiveCommand.Create(this.WhenAny(m => m.TimerState, m => m.Value != TimerState.Running)); Start.Subscribe(_ => StartImpl()); Stop = ReactiveCommand.Create(this.WhenAny(m => m.TimerState, m => m.Value != TimerState.Initial)); Stop.Subscribe(_ => StopImpl()); LapTimes = new ReactiveList <LapTime>(); Lap = ReactiveCommand.CreateAsyncObservable(this.WhenAny(m => m.TimerState, m => m.Value == TimerState.Running), _ => Observable.Return(stopWatch.Elapsed)); Lap.Subscribe(x => LapTimes.Add(new LapTime(x, x - (LapTimes.LastOrDefault()?.Elapsed ?? TimeSpan.Zero)))); this.WhenAny(vm => vm.TimerState, oc => oc.Value == TimerState.Initial).Subscribe(_ => LapTimes.Reset()); Observable.Interval(TimeSpan.FromMilliseconds(10d)) .Select(_ => GetFormattedElapsed(stopWatch.Elapsed)) .ToProperty(this, vm => vm.Elapsed, out elapsed, GetFormattedElapsed(TimeSpan.Zero), scheduler); }