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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:13:23+00:00 2026-06-12T21:13:23+00:00

I want to raise an event every time each hour has passed in system

  • 0

I want to raise an event every time each hour has passed in system clock.
For example, I run my program at 7:45 am then the event should be raised at 8:00 am, not at 8:45 am.
After the event raised at 8:00 am, then this event should be raised at every hour 9:00 am, 10:00 am, 11:00 am, etc…

Can anyone help me to show some code…
I use C#.net…
Thanks in advance…

UPDATE:

Now I get the simple solution for my question. Therefore I would like to share this solution. lboshuizen’s answer is already correct. My answer is same logic with lboshuizen’s answer but more detail and exact.

Firstly it needs to use Timer. Timer basically works based on milliseconds which sometimes needs additional calculation. Therefore, I would like to implement milliseconds to minute formatting function as first.

int CalculateMillisecondUntilNextHour()
{
     int REMAIN_MINUTE = 60 - DateTime.Now.Minute;
     DateTime now = DateTime.Now;
     DateTime nexthour = now.AddMinutes((minute)).AddSeconds(now.Second * -1).AddMilliseconds(now.Millisecond * -1);

     TimeSpan interval = nexthour - now;
     return (int)interval.TotalMilliseconds;
}

void CheckEachHourPassed()
{
     System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
     t.Interval = CalculateMillisecondUntilNextHour();
     t.Tick += new EventHandler(t_Tick);
     t.Enabled = true;
}

void t_Tick(object sender, EventArgs e)
{
     MessageBox.Show("Raise Your Event");
     t.Interval = CalculateTimerInterval(REMAIN_MINUTE);
}

At here, the main working function is CheckEachHourPassed(). Call this function where you want to start your event scheduler.

  • 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-06-12T21:13:24+00:00Added an answer on June 12, 2026 at 9:13 pm

    Pseudo code (implementation is left as an excercise to the reader)

    var currentTime = Time.Now()
    var deltaMinutes  = Calculate_minutes_till_next_full_hour(currentTime);
    wait(deltaMinutes);
    var timer = new timer();
    timer.Every().Minutes(60).Execute(() => Code());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to raise an event that shows up in the system event viewer
-I want to raise an event whenever method showmessage is called.I want to catch
I want to raise an event from a .NET class, and receive this event
I want to raise the some event in Java after finishing the reading of
I want to raise an event on a stub object whenever a certain property
in my moq setup, i want to raise a delegate event. How do i
I have an ActiveX control (an OCX file) which raises an event. I want
I don't want multiple windows, each with its own UI thread, nor events raised
$Hello_all, a simple question, in a project I want to raise the property changed
I want to do something like this: class Dictable: def dict(self): raise NotImplementedError class

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.