protected void ProcessNode(IPAddress address, IPStatus status) { long roundTripTime = 0; if (status == IPStatus.TtlExpired || status == IPStatus.Success) { Ping pingIntermediate = new Ping(); try { //Compute roundtrip time to the address by pinging it PingReply reply = pingIntermediate.Send(address, _timeout); roundTripTime = reply.RoundtripTime; status = reply.Status; } catch (PingException e) { //Do nothing System.Diagnostics.Trace.WriteLine(e); } finally { pingIntermediate.Dispose(); } } TracertNode node = new TracertNode(address, roundTripTime, status); lock (_nodes) { _nodes.Add(node); } if (RouteNodeFound != null) { RouteNodeFound(this, new RouteNodeFoundEventArgs(node, this.IsDone)); } this.IsDone = address.Equals(_destination); lock (_nodes) { if (!this.IsDone && _nodes.Count >= _maxHops - 1) { ProcessNode(_destination, IPStatus.Success); } } }
protected internal RouteNodeFoundEventArgs(TracertNode node, bool isDone) { this._node = node; this._isLastNode = isDone; }