如题
代码如下:
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()}"); } }