| Код | System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping(); System.Net.NetworkInformation.PingReply reply = p.Send("ya.ru"); if (reply.Status == System.Net.NetworkInformation.IPStatus.Success) { MessageBox.Show(reply.RoundtripTime.ToString()); }
|
или так:
| Код | ..... System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping(); p.PingCompleted += new System.Net.NetworkInformation.PingCompletedEventHandler(p_PingCompleted); p.SendAsync("www.google.com", null); }
void p_PingCompleted(object sender, System.Net.NetworkInformation.PingCompletedEventArgs e) { System.Net.NetworkInformation.PingReply reply = e.Reply; if (reply.Status == System.Net.NetworkInformation.IPStatus.Success) { MessageBox.Show(reply.RoundtripTime.ToString()); } }
|
|