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);
                }
            }
Beispiel #2
0
        public void OnError(PingError error)
        {
            if (error.Fatal)
            {
                ConsoleDisplay.Fatal(error.Message, error.Exception);

                // Exit on fatal error
                Helper.ExitWithError();
            }
            else
            {
                ConsoleDisplay.Error(error.Message, error.Exception);
            }
        }
 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);
     }
 }
Beispiel #4
0
 private void OnPingError(int epIndex, Exception ex) => PingError?.Invoke(this, new PingErrorEventArgs(epIndex, ex));