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

  • Home
  • SEARCH
  • 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 92209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:09:04+00:00 2026-05-10T23:09:04+00:00

I’m working on a little web crawler that will run in the system tray

  • 0

I’m working on a little web crawler that will run in the system tray and crawl a web site every hour on the hour.

What is the best way to get .NET to raise an event every hour or some other interval to perform some task. For example I want to run an event every 20 minutes based on the time. The event would be raised at:

00:20 00:40 01:00 01:20 01:40 

and so on. The best way I can think of to do this is by creating a loop on a thread, that constantly checks if the time is divisible by a given interval and raises a callback event if the time is reached. I feel like there has got to be a better way.

I’d use a Timer but I’d prefer something that follows a ‘schedule’ that runs on the hour or something along those lines.

Without setting up my application in the windows task scheduler is this possible?

UPDATE:
I’m adding my algorithm for calculating the time interval for a timer. This method takes a ‘minute‘ parameter, which is what time the timer should trigger a tick. For example, if the ‘minute‘ parameter is 20, then the timer will tick at the intervals in the timetable above.

int CalculateTimerInterval(int minute) {     if (minute <= 0)         minute = 60;     DateTime now = DateTime.Now;      DateTime future = now.AddMinutes((minute - (now.Minute % minute))).AddSeconds(now.Second * -1).AddMilliseconds(now.Millisecond * -1);      TimeSpan interval = future - now;      return (int)interval.TotalMilliseconds; } 

This code is used as follows:

static System.Windows.Forms.Timer t; const int CHECK_INTERVAL = 20;   static void Main() {     t = new System.Windows.Forms.Timer();     t.Interval = CalculateTimerInterval(CHECK_INTERVAL);     t.Tick += new EventHandler(t_Tick);     t.Start(); }  static void t_Tick(object sender, EventArgs e) {     t.Interval = CalculateTimerInterval(CHECK_INTERVAL); } 
  • 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. 2026-05-10T23:09:04+00:00Added an answer on May 10, 2026 at 11:09 pm

    System.Timers.Timer. If you want to run at specific times of the day, you will need to figure out how long it is until the next time and set that as your interval.

    This is just the basic idea. Depending on how precise you need to be you can do more.

    int minutes = DateTime.Now.Minute; int adjust = 10 - (minutes % 10); timer.Interval = adjust * 60 * 1000;   
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 79k
  • Answers 79k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Three.foo is trying to override Two.foo(), but it doesn't do… May 11, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer I'd personally use php for this (but I'm rubbish at… May 11, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer For frequent uploads of small files, the fastest way would… May 11, 2026 at 4:01 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.