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 192651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:26:37+00:00 2026-05-11T16:26:37+00:00

I wrote a VB.NET Windows Service, which works fine. I have only one issue

  • 0

I wrote a VB.NET Windows Service, which works fine. I have only one issue with it. I want the service to execute on the half hour and top of the hour marks (e.g. 9:00, 9:30, 10:00, 10:30, 11:00, etc etc etc). I am using the following code:

Protected Overrides Sub OnStart(ByVal args() As String)
    ' Add code here to start your service. This method should set things
    ' in motion so your service can do its work.
    Dim oCallBack As New TimerCallback(AddressOf TimedEvent)
    oTimer = New System.Threading.Timer(oCallBack, Nothing, 300000, 300000)
    EventLog.WriteEntry("CCFinalizeService has begun successfully." , _
                        System.Diagnostics.EventLogEntryType.Information)

End Sub

This code works, however, if the service starts at, say, 10:15, then it executes at 10:15, 10:45, 11:15, 11:45. How do I make it so it always executes on the 30 minute and top of the hour marks?

  • 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-11T16:26:37+00:00Added an answer on May 11, 2026 at 4:26 pm

    You just need to modify the dueTime parameter in the Timer creation method

    Dim now As Date = DateTime.Now
    Dim dueTime As Integer ' milliseconds to the next half-hour
    dueTime = 1800000 - (now.Minute Mod 30) * 60000 - now.Second * 1000 - now.Millisecond
    oTimer = New System.Threading.Timer(oCallBack, Nothing, dueTime, 1800000)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VB.NET Windows Service that I wrote and it works fine. In
I have a .NET Windows serivce protected with {smartassembly} which works fine, except that
One of my coworkers wrote a .NET windows service that converts .doc to .docx
I have one server and three clients in which a windows service is running
I have created a .NET Windows Service which performs certain actions and generates reports.
I had written one windows service in C#.NET which fires on every miniutes... I
I have a asp.net webservice running in windows server 2003, i want it read/write
I have developed a .NET Windows Service (in VS2010) that needs to: Access shared
A few years ago I wrote a WCF service, which runs on a Windows
I've got a WCF service running on a Windows 2003 Server, which I wrote

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.