Ping Problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Asprisa
    New Member
    • Oct 2007
    • 30

    Ping Problems

    Hi Guys,

    I am developing a small app just to check our servers are still online, at the moment i have got the my.computer.net work.ping pinging 12 of our servers and changing a label to say either server online or server offline, i am trying to get this to happen every 15 seconds, i have tried loops etc but it freezes the app, i came across application.doe vents which enabled the form to load without freezing. I was wondering if someone knows of a better way of doing this without the app freezing.

    Cheers!

    Jay!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Use the System.Threadin g.Timer object.

    Comment

    • pootle
      New Member
      • Apr 2008
      • 68

      #3
      Originally posted by Asprisa
      Hi Guys,

      I am developing a small app just to check our servers are still online, at the moment i have got the my.computer.net work.ping pinging 12 of our servers and changing a label to say either server online or server offline, i am trying to get this to happen every 15 seconds, i have tried loops etc but it freezes the app, i came across application.doe vents which enabled the form to load without freezing. I was wondering if someone knows of a better way of doing this without the app freezing.

      Cheers!

      Jay!
      Hi Jay,

      It probably "freezes" the app because you are doing everything from the main thread - the one that also manages the GUI. Have you tried making the pings in seperate threads?

      Regards.

      Comment

      • Asprisa
        New Member
        • Oct 2007
        • 30

        #4
        Hi Guys!

        I have tried playing with the Use the System.Threadin g.Timer object and it seemed unsuccessful. I have moved the ping code into a sperate function and am calling the function from the form load, the first ping works fine, the app takes a little time to load but when i loop the code after a timer etc.. the app freezes until the loop has continued, this is not an issue if all i was going to do was loop the code but i wish to do more with the app and i cannot allow it to freeze, any suggestions guys! and thanks for your input so far, very useful learning for me!

        Regards

        Jay!

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Well the System.Threadin g.Timer is different then the other timer object, this one actually creates/runs in its own thread. If you tried that Timer (not the timer you drag/drop on the GUI designer) and it didn't work, you might have to go with full on threads.

          Comment

          Working...