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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:39:04+00:00 2026-05-15T14:39:04+00:00

I want to trigger KillZombies every night at midnight. The problem I’m having is

  • 0

I want to trigger KillZombies every night at midnight.
The problem I’m having is that the first timer interval is retained and not reset to 86400000 milliseconds as I’m trying to do in my method.

Is there any way to remove the old interval and replace it with a new one?

System.Timers.Timer Timer = new System.Timers.Timer();
Timer.Elapsed += new ElapsedEventHandler(KillZombies);
Timer.Interval = MillisecondsToMidnight;
Timer.Start()

private void KillZombies(object source, ElapsedEventArgs e)
{
//Kill zombies
Timer.Interval = 86400000; //Milliseconds per 24 hours
}
  • 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-15T14:39:05+00:00Added an answer on May 15, 2026 at 2:39 pm

    FWIW, when using Timers, I always set the AutoReset property to false. This prevents the timer from starting up again, so you have to call Timer.Start() to get it to start counting again. This would avoid the extra calls to Stop()

    Also, to be explicit, I would have a function that calculates milliseconds to midnight each time and assign that to the timer’s interval every time. Would make your code more clear. And also, if you use Timer.AutoRest = false, the timer won’t start counting until you call Timer.Start(), which means if you put the Start() call at the end of your KillZombies method and that method takes 5 seconds to execute, your timer should then be 86400000 - 5000. That 5 second shift would add up over time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a process that runs continuesly. I want to trigger that process every
I want to create a trigger in Oracle 11g. The problem is that I
I want the trigger to run after each and every record that gets inserted.
I came in to scenario that I want to trigger service on specific time.
I've got an after insert trigger that works well. However, I want it to
I want to trigger a form submit, but not have my usual handlers for
I want to trigger an event that causes the ScrollPane to start scrolling up
I want a trigger to fire only when UPDATEs are user-initiated (not me running
My OnChange event does not work properly - I want to trigger a function
I have an initialise function in my app that I want to trigger when

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.