111,094
社区成员




private void button1_Click_1(object sender, EventArgs e)
{
string str="123";
Ping p = new Ping();
p.PingCompleted += new PingCompletedEventHandler(test);
//p.PingCompleted += test;
p.SendAsync("192.168.1.101", 1);
}
private void test(object sender, PingCompletedEventArgs e)
{
if (e.Reply.Status == IPStatus.Success)
{
MessageBox.Show("成功");
}
else
{
MessageBox.Show("失败");
}
}
public class SePing : Ping
{
/// <summary>
/// 发送内容
/// </summary>
public string Msg { get; set; }
/// <summary>
/// 进入方式
/// </summary>
public int effect { get; set; }
/// <summary>
/// 停留时间
/// </summary>
public int speedStay { get; set; }
}
然后从object sender中获取。 private void button1_Click_1(object sender, EventArgs e)
{
Ping p = new Ping();
p.PingCompleted += new PingCompletedEventHandler(ping_Complete);//1
for (int i = 101; i < 105; i++)
{
string str = "字符串" + i;
p.SendAsync("192.168.1." + i, 1);
}
}
private void ping_Complete(object sender, PingCompletedEventArgs e)
{
if (e.Reply.Status == IPStatus.Success)
{
//如果ping成功则发送str到显示屏
MessageBox.Show("成功");
}
else
{
MessageBox.Show("失败");
}
}