async public void PingHostAsync() { try { var pingTask = Task.Run(() => { Uri myUri = new Uri(Host); clsRollingAverage pingLatency = new clsRollingAverage(10); clsRollingAverage pingPacketLoss = new clsRollingAverage(10); try { using (var pinger = new Ping()) { for (var f = 0; f < 10; f++) { PingReply reply = pinger.Send(myUri.Host, 2000); if (reply.Status == IPStatus.Success) { pingPacketLoss.Add((int)reply.RoundtripTime); pingPacketLoss.Add(0); Program.SendAlert($"Ping {myUri.Host} {reply.RoundtripTime:0} ms {pingPacketLoss.CurrentAverage:0.0}%"); } else { pingPacketLoss.Add(100); Program.SendAlert($"Ping {myUri.Host} {reply.Status} ms {pingPacketLoss.CurrentAverage:0.0}%"); } } } } catch (PingException ex) { Program.SendAlert($"Ping error {myUri.Host} {ex.Message}"); } }); } catch (Exception ex) { Program.SendAlert($"Ping error {Name} {ex.Message}"); } }