private async Task GetPingData(object parameter) { IsPinging = true; OnPropertyChanged(nameof(IsPinging)); while (IsPinging) { var result = await _pingStatus.PingServer(); _totalNumberOfPingsCollected++; if (result.Status != IPStatus.Success) { PacketsLost++; OnPropertyChanged(nameof(PacketsLost), nameof(PercentageOfLostPackets)); } else { PingPoints.Add(result.RoundtripTime); if (PingPoints.Count > 20) { PingPoints.RemoveAt(0); } AveragePing = PingPoints.Average(); OnPropertyChanged(nameof(AveragePing)); if (PacketsLost != 0) { OnPropertyChanged(nameof(PercentageOfLostPackets)); } } } }
private void ResetStatistics() { PingPoints.Clear(); PacketsLost = 0; _totalNumberOfPingsCollected = 0; AveragePing = 0; OnPropertyChanged(nameof(SelectedAddress), nameof(AveragePing), nameof(PacketsLost)); }