Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3842378
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:47:06+00:00 2026-05-19T15:47:06+00:00

I hope I am asking this correctly… What I am looking to do is

  • 0

I hope I am asking this correctly…

What I am looking to do is ping a server every 30 minutes to an hour or so and to send an email if the server is not pingable. At the moment, all I have is the following code:

Private Sub Button1_Click(ByVal sender As System.Object,
                          ByVal e As System.EventArgs) Handles Button1.Click
    If My.Computer.Network.Ping("209.85.143.99") Then
        MsgBox("Server pinged successfully.")
    Else
        MsgBox("Ping request timed out.")
    End If
End Sub

I am creating the project in Visual Studio 2010. All it does now is check if it can ping a server. I would like it to run this code every 30min. Can anyone tell me how I can do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:47:07+00:00Added an answer on May 19, 2026 at 3:47 pm

    The code that you already you have is a good start, but (as you probably know) it will only be executed when the user clicks the button. If you need to ping the server periodically every 30 minutes, you will need to start a timer and run your code each time the timer has elapsed.

    A Timer control is already provided for you by the .NET Framework, and it’s quite simple to take advantage of its functionality. Here’s a quick step-by-step:

    1. In Design Mode (where you can edit your form from inside of Visual Studio), scroll down to the “Components” tab in the Toolbox and drag the “Timer” control to your form.

    2. A new Timer control will appear in a gray box at the bottom of your screen. Use the Properties Window to give it a name and set its properties:

      • Name: pingTimer
      • Enabled: True
      • Interval: 60000
    3. Switch to code view and add a class-level variable of type Integer to your form. This variable will be used to keep track of how many seconds have elapsed so far.

      The reason you have to do this is the Interval of the Timer is measured in milliseconds, which makes its maximum value far less than 30 minutes. By setting the interval to “60000”, the timer will “tick” every 1 minute, and on each tick, you will increment the variable keeping track of the total number of timer ticks. When the value of that variable reaches 30 (indicating 30 minutes has elapsed), you will reset it to 0 and run your ping code.

    4. Add an event handler method for the Timer.Tick event. This is where the code that I just talked about above will go.

    So, your final code might look something like this:

    ' Class-level variable to keep track of the number of "ticks" so far
    Private elapsedTime As Integer = 0
    
    Private Sub pingTimer_Tick(ByVal sender As System.Object,
                               ByVal e As System.EventArgs) Handles pingTimer.Tick
        ' Check the time that has elapsed so far
        If elapsedTime >= 30 Then
            ' It has been 30 minutes, so reset the elapsed time count
            elapsedTime = 0
    
            ' And do the ping
            If My.Computer.Network.Ping("209.85.143.99") Then
                MsgBox("Server pinged successfully.")
            Else
                MsgBox("Ping request timed out.")
            End If
        Else
            ' It has not yet been 30 minutes, so increment the elapsed time count
            elapsedTime += 1
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope I'm asking this correctly: I have a project Projects.Client I have my class
I hope this question is not 'controversial' - I'm just basically asking - has
First time using this service for a question. I hope I am not asking
I'm not sure if I'm even asking this question correctly. I just built my
I hope I'm not using stackoverflow.com in the wrong way: asking this question! Recently
Hope this is the right place to be asking this, so my apologies if
Hope this is not a dupe. I would like to be able to do
I apologize ahead of time if I am not asking this properly.. it is
I'm new here and I hope I'm not asking something which has already been
Okay, so hopefully I am asking this question correctly: I set up my user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.