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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:20:33+00:00 2026-05-18T22:20:33+00:00

I would like to have an event triggered in my app which runs continuously

  • 0

I would like to have an event triggered in my app which runs continuously during the day at a certain time, say at 4:00pm. I thought about running the timer every second and when the time is equal to 4:00pm run the event. That works. But I’m wondering if there’s a way to just get the callback once at 4:00pm and not having to keep checking.

  • 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-18T22:20:34+00:00Added an answer on May 18, 2026 at 10:20 pm

    How about something like this, using the System.Threading.Timer class?

    var t = new Timer(TimerCallback);
    
    // Figure how much time until 4:00
    DateTime now = DateTime.Now;
    DateTime fourOClock = DateTime.Today.AddHours(16.0);
    
    // If it's already past 4:00, wait until 4:00 tomorrow    
    if (now > fourOClock)
    {
        fourOClock = fourOClock.AddDays(1.0);
    }
    
    int msUntilFour = (int)((fourOClock - now).TotalMilliseconds);
    
    // Set the timer to elapse only once, at 4:00.
    t.Change(msUntilFour, Timeout.Infinite);
    

    Note that if you use a System.Threading.Timer, the callback specified by TimerCallback will be executed on a thread pool (non-UI) thread—so if you’re planning on doing something with your UI at 4:00, you’ll have to marshal the code appropriately (e.g., using Control.Invoke in a Windows Forms app, or Dispatcher.Invoke in a WPF app).

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

Sidebar

Related Questions

I would like to have a Spinner updated upon an onTap event in my
I would like to have both a hover and remove hover event. The nodes
I have 2 event handlers: Y.all(.ptl).on(mouseover, handleOverlay); Y.all(.ptl).on(mouseout, handleOverlay); And I would like to
I have a JPanel, which I would like to detect the following events (1)
I would like to have a field which is updated on every change(insertion, modification),
I have three views in my app and I would like to be able
I have a long list of elements which I would like to scroll while
I have a web app that I'm working on that I would like the
I'm working on a JQM app and would like to have the user choose
So in my project i would like have a nice treeview that has images.

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.