万金流
初次使用博客园,目前感觉还不错。 不知不觉用了4年零4个月了,越来越喜欢博客园。

如题

代码如下:

static void Main(string[] args)
        {
            //ThreadPool.SetMaxThreads(2, 1);
            for (int i = 150; i <= 190; i++)
            {
                //ThreadPool.QueueUserWorkItem(new WaitCallback(pingit), "120.27.234." + i);
                pingit("120.27.234." + i);
            }
            Console.ReadKey();
        }
        static void pingit(object x)
        {
            string y = (string)x;
            Ping ping = new Ping();
            PingReply pr;
            pr = ping.Send(y);
            if(pr.Status==IPStatus.Success)
            {
                Console.WriteLine($"{y} is alive.");
            }
            else
            {
                Console.WriteLine($"{x.ToString()}");
            }
        }

 

posted on 2020-04-09 20:18  万金流  阅读(398)  评论(0编辑  收藏  举报