Continuous SendAsync Ping in VB.Net

Posted on 2009-02-24
Last Modified: 2013-11-07
I have 4 servers that I need to ping.  I can easily ping them all once with .SendAsync pinging method.  Works great!  I get my response back nicely from the PingCompleted Event.

1. I have setup 4 Ping Objects, one for each server
2. Each has it's own PingComplete handler to update screen reporting
3. I execute the Server1.SendAsync(address, address) for each (Server1-Server4 respectively)

How can I have their pings repeat once a second till I send a Server1.SendAsyncCancel?  This will be a separate button on the screen labelled 'STOP'  I will send a .SendAsyncCancel for each Ping object.  Server1 - Server4 respectively again.

I tried placing an additional Server1.SendAsync(address, address) statement at the end of the PingComplete event to execute another ping and the pings are cruising at warp speed.  I definitely don't want to add a system.thread sleep statment anywhere in there.  That will pause the whole app.  The .SendAsyncCancel sometimes get's ignored it's going so fast.

Does anyone have a good VB.Net example of pinging multiple address multiple times?  And reporting on the reply for each.  (return time, ip address, etc...)
Question by:gbrdelormf
    LVL 8

    Expert Comment

    If you are truly sending async then they should be running in their own thread and a Thread.Sleep will not halt your application.  If in fact this is not the case, then try creatiing timers that fire every second and call the ping method.  You can have a start and stop button that will just start and stop the timers that are calling the ping methods.

    Author Comment

    I created 4 timers, one for each server.  Set the interval to 1000.  Placed the Server1.SendAsync(...) statement in there.  Test Run.  If the ping has not returned with 1000ms, it errors that I cannot launch another SendAsync while one is active.  Any ideas?
    LVL 8

    Accepted Solution

    You can use a boolean flag to check if the ping method has completed.  Set it true at the end of the ping method and in your timer check to see if it has completed and if so, then run it again.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now