private void OnPingCompleted(object sender, PingCompletedEventArgs e) { PingTaskState state = e.UserState as PingTaskState; if (state != null) { if (e.Cancelled || Executor.Command.Stopping) { state.Ping.Dispose(); return; } PingHostInfo result = new PingHostInfo(this, state.IPAddress, e.Reply, e.Error, Buffer.Length); Executor.WriteInfo(result); if (state.RemainingCount == 0) { state.Ping.Dispose(); } else { SendAsyncInternal(state); } } }
internal override void WriteInfo(PingHostInfo result) { lock (syncRoot) { Statistics.Add(result); } DecrementItemCount(); }
public void Add(PingHostInfo result) { IPAddress address = result.Address; if (!items.ContainsKey(address)) { items[address] = new PingHostStatistics(result.HostName, result.HostNameWithAddress, address); } items[address].Replies.Add(result.Reply); }
public void Send() { using (Ping ping = new Ping()) { foreach (IPAddress ip in Addresses) { WriteMessage(ip); for (int i = 0; i < Count; i++) { if (Executor.Command.Stopping) { return; } PingReply reply = null; Exception error = null; try { reply = ping.Send(ip, Timeout, Buffer, PingOptions); } catch (PipelineStoppedException) { throw; } catch (Exception exc) { error = exc; } PingHostInfo info = new PingHostInfo(this, ip, reply, error, Buffer.Length); Executor.WriteInfo(info); } Executor.WriteStatistics(ip); } } }
internal override void WriteInfo(PingHostInfo info) { info.WriteToHost(Command); Statistics.Add(info); }
internal abstract void WriteInfo(PingHostInfo info);
public void Send() { using (Ping ping = new Ping()) { foreach (IPAddress ip in Addresses) { WriteMessage(ip); for (int i = 0; i < Count; i++) { if (Executor.Command.Stopping) return; PingReply reply = null; Exception error = null; try { reply = ping.Send(ip, Timeout, Buffer, PingOptions); } catch (PipelineStoppedException) { throw; } catch (Exception exc) { error = exc; } PingHostInfo info = new PingHostInfo(this, ip, reply, error, Buffer.Length); Executor.WriteInfo(info); } Executor.WriteStatistics(ip); } } }