如何连续ping [英] how to ping Continuously
本文介绍了如何连续ping的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好..
即时创建应用程序以检查连接状态但我的问题我必须单击按钮才能获得结果,以便如何从该ping获得重播或连续,/ >
这是我的代码
使用系统;
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Data;
使用 System.Drawing;
使用 System.Linq;
使用 System.Text;
使用 System.Windows.Forms;
使用 System.Threading;
使用 System.Net.NetworkInformation;
命名空间 ping_test_2
{
public partial class Form1:Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click( object sender,EventArgs e)
{
Ping p = new Ping();
PingReply r;
string s;
s = textBox1.Text;
r = p.Send(s);
if (r.Status == IPStatus.Success)
{
listBox1.Items.Add( Ping to + s.ToString()+ r.Address.ToString()+ ] + 成功
+ 响应延迟= + r.RoundtripTime.ToString() + ms + \\\
跨度>);
button2.BackColor = Color.Green;
}
else if (r.Status == IPStatus.TimedOut)
{
button2.BackColor = Color.Red;
}
}
}
}
你们中的任何人都可以帮助我这个plz
解决方案
使用计时器: http://www.dotnetperls.com/timer [< a href =http://www.dotnetperls.com/timertarget =_ blanktitle =新窗口> ^ ]
尝试使用C#5中的TAP和IProgress进行连续异步Ping [ ^ ]。
hi everyone ..
im creating application to check connection Status but my problem i must click button to get result so how it is possible to get replay or Continuously from that ping ,,
this is my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Net.NetworkInformation;
namespace ping_test_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Ping p = new Ping();
PingReply r;
string s;
s = textBox1.Text;
r = p.Send(s);
if (r.Status == IPStatus.Success)
{
listBox1.Items.Add( "Ping to " + s.ToString() + r.Address.ToString() + "]" + " Successful"
+ " Response delay = " + r.RoundtripTime.ToString() + " ms" + "\n");
button2.BackColor = Color.Green;
}
else if (r.Status == IPStatus.TimedOut)
{
button2.BackColor = Color.Red;
}
}
}
}
can anyone of you help me with this plz
解决方案
Use a timer : http://www.dotnetperls.com/timer[^]
Try Continuous asynchronous Ping using TAP and IProgress in C#5[^].
这篇关于如何连续ping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文