110,533
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
Parallel.For(0, 20, Test);
Console.ReadLine();
}
public static void Test(int i)
{
Ping p = new Ping();
PingReply reply = p.Send("www.baidu.com"); //发送主机名或Ip地址
StringBuilder sb;
if (reply.Status == IPStatus.Success)
{
sb = new StringBuilder();
sb.AppendLine(string.Format("Address: {0} ", reply.Address.ToString()));
sb.AppendLine(string.Format("RoundTrip time: {0} ", reply.RoundtripTime));
sb.AppendLine(string.Format("Time to live: {0} ", reply.Options.Ttl));
sb.AppendLine(string.Format("Don't fragment: {0} ", reply.Options.DontFragment));
sb.AppendLine(string.Format("Buffer size: {0} ", reply.Buffer.Length));
Console.WriteLine(i+"---"+ sb.ToString());
}
}