1 ping类
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.NetworkInformation;
using System.Threading;
using System.Windows.Forms;
namespace TestLoadForm
{
class PingIp
{
Thread thread;
int ping_time = 2000;
System.Timers.Timer timer;
public string Ip;
public delegate void PingHandle(string ip,bool flag);
public event PingHandle pingEvent;
public PingIp(string ip)
{
Ip = ip;
thread = new Thread(new ThreadStart(RunSecondThread));
thread.Start();
}
void RunSecondThread()
{
timer = new System.Timers.Timer(ping_time);
timer.AutoReset = true;
本文介绍了如何利用C#的Ping类进行网络探测,从而判断设备是否在线。通过创建Ping对象,发送请求并分析响应,可以有效地检测目标设备的网络连通性。
订阅专栏 解锁全文
1931

被折叠的 条评论
为什么被折叠?



