PING clone - waiting in between pings

  • Thread starter Thread starter G-Oker
  • Start date Start date
G

G-Oker

Guest
Hello, I'm trying to create a PNG type clone for an internal app I am creating.

I can get the pings results, but I am trying to get it to waiting in between pings (like the CMD command does).

So, ping, display results, wait a few secs, do again until iterration =0

private void button5_Click(object sender, EventArgs e)
{
int iterration = 6;
Ping p = new Ping();
PingReply r;
string s;
s = "8.8.8.8";

r = p.Send(s, 1000);

while (iterration > 0)
{
if (r.Status == IPStatus.Success)
{
_PINGoutputBox.AppendText("Ping to " + s.ToString() + "[" + r.Address.ToString() + "]" + " Successful");
_PINGoutputBox.AppendText(" Response delay = " + r.RoundtripTime.ToString() + " ms" + "\n");
}
else
{
_PINGoutputBox.AppendText("Ping to " + s.ToString() + " failed");
_PINGoutputBox.AppendText(" Response delay = " + r.RoundtripTime.ToString() + " ms");
_PINGoutputBox.AppendText(r.Status.ToString() + "\n");
}
iterration--;
}

above is the code I have at the moment.

Ive looked at making the application wait, but I dont think "pausing" the program is the correct soultion.

If any one could advise, that would be super :-)


Of course , if there is a better wait of copying the CMDs Ping command, I would love to hear about that also :-)


Many Thanks

Continue reading...
 
Back
Top