private void Ping_PingCompleted(object sender, PingCompletedEventArgs e) { try { if (!e.Cancelled) { if (e.UserState != null) { PingReplied?.Invoke((IPAddress)e.UserState, e.Reply); } returnedIndexes += 1; if (returnedIndexes >= expectedIndexes) { Finished?.Invoke(); } } } catch (Exception ex) { if (e != null && e.Reply != null && e.Reply.Address != null) { PingError?.Invoke(e.Reply.Address, ex.Message); } Logging.Logger.Log("Ping_PingCompleted() :: Exception :: " + ex.Message); } }
private void StartPing(IPAddress ipAddress, int index) { try { var ping = new Ping(); ping.PingCompleted += Ping_PingCompleted; queuedPings.Add(ping); ping.SendAsync(ipAddress, timeout, ipAddress); } catch (Exception ex) { PingError?.Invoke(ipAddress, ex.Message); Logging.Logger.Log("PingNodes() :: Exception :: " + ex.Message); } }
private void OnPingError(int epIndex, Exception ex) => PingError?.Invoke(this, new PingErrorEventArgs(epIndex, ex));