public void IntervalTimerTest(MainForm frm) { IntervalTimer timer = new IntervalTimer(); long loopMax = 100000000; long sumNum = 0; try { _msg.Length = 0; _msg.Append("IntervalTimerTest started ...\r\n"); WriteMessageToLog(_msg.ToString()); timer.StartTimer(); for (long num = 1; num <= loopMax; num++) { sumNum += num; } timer.StopTimer(); _msg.Length = 0; _msg.Append(Environment.NewLine); _msg.Append("loopMax = "); _msg.Append(loopMax.ToString("#,##0")); _msg.Append(Environment.NewLine); _msg.Append("sumNum = "); _msg.Append(sumNum.ToString("#,##0")); _msg.Append(Environment.NewLine); _msg.Append("Elapsed time = "); _msg.Append(timer.ElapsedTime.ToString("#,##0")); _msg.Append(" milliseconds"); _msg.Append(Environment.NewLine); WriteMessageToLog(_msg.ToString()); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); WriteMessageToLog(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { _msg.Length = 0; _msg.Append("\r\n... IntervalTimerTest finished."); WriteMessageToLog(_msg.ToString()); } }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState) { if (suspensionState.Any()) { // use cache value(s) if (suspensionState.ContainsKey(nameof(SelectedTripData))) { SelectedTripData = suspensionState[nameof(SelectedTripData)] as TripData; } // clear any cache suspensionState.Clear(); } else { // use navigation parameter if (parameter.GetType().Equals(typeof(TripData))) { SelectedTripData = parameter as TripData; } } ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); if (SelectedTripData.IsTripStarted == true) { CurrentTripDataRepo.DriveValue = EnumHelper.DeParse(DriveStateStatus.TripStarted); CurrentTripDataRepo.StartTime = SelectedTripData.TripStartTime; CurrentTripDataRepo.CurrentUser = SelectedTripData.CustomerName; smartTimer.StopTimer(); upTimer.Start(); CurrentTripDataRepo.IsTripStarted = true; StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); } else { CurrentTripDataRepo.CurrentUser = SelectedTripData.CustomerName; CurrentTripDataRepo.CurrentPickupMunites = Math.Round((SelectedTripData.TripStartTime - DateTime.Now).TotalMinutes) <= 0 ? 0.0 : Math.Round((SelectedTripData.TripStartTime - DateTime.Now).TotalMinutes); smartTimer.StartTimer(() => { if (CurrentTripDataRepo.CurrentPickupMunites != 0) { CurrentTripDataRepo.CurrentPickupMunites--; } else { smartTimer.StopTimer(); } }); } geoLocationService.DesiredAccuracyInMeters = 10; geoLocationService.MovementThreshold = 5; var initializationSuccessful = await geoLocationService.InitializeAsync(); if (initializationSuccessful) { await geoLocationService.StartListeningAsync(); CurrentTripDataRepo.CurrentUserPosition = geoLocationService.CurrentPosition; if (geoLocationService.IsGeolocationAvailable) { CurrentTripDataRepo.IsPositonAvailable = true; } } if (geoLocationService.IsListening) { geoLocationService.PositionChanged += GeoLocationService_PositionChanged; } NavigationService.FrameFacade.BackRequested += FrameFacade_BackRequested; await Task.CompletedTask; }