• 0

Creating a timer in ASP.NET?


Question

I want to create a time in ASP.NET, however, I am not sure how to do that.

Here is my situation:

I need to be able to do something about a specific time each day. Can I do this in ASP.NET?

i.e. Every morning, I need it to query a database and email people if there are records that match a criteria.

How can I get ASP.NET to queury at a specific time. This is a fairly low traffic website, so I can't incorporate a check with every page request.

Any ideas?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Look up the docs for System.Threading.Timer. This basically calls a method at regular intervals.

Here is an example:

// Calculate length of time remaining until 9am.

TimeSpan timeOfDay = new TimeSpan(9, 0, 0);

TimeSpan dueTime = timeOfDay - DateTime.Now.TimeOfDay;

if (dueTime ;)

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.