Link to home
Start Free TrialLog in
Avatar of T Hoecherl
T HoecherlFlag for United States of America

asked on

Setting a timer to run on the hour

I have a vb.net program that runs and accomplishes several tasks every 60 minutes.  I am satisfied with how it is working, but it runs every hour from the time I launch the application.  If I launch the application at 8:50 am, it runs then and again at 9:50, etc.  I would like it to run at 9:00, 10:00, etc.  Is there a way to accomplish this with VB.net?
Avatar of Luis Pérez
Luis Pérez
Flag of Spain image

Set the Interval property of the Timer to 1000 (it will check every 1 second).

In the code, write this:
Private Sub Timer1_Timer(sender As Object, e As System.EventArgs)
    If Date.Now.ToString("HH:mm:ss").EndsWith(":00:00") Then
        'Start the Task
    End If
End Sub

Hope that helps.
Every second would be a bit extreme. I would set it to every minute.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of T Hoecherl

ASKER

Perfect, Idle_Mind.  Thank you.

T