We help IT Professionals succeed at work.

Database Polling

I am about to write a windows service that is going to poll the database every predefined minutes, it will look at a schedule table, decide if anything is due to execute then add it to the execution table.

What is the best way to achieve this, the config file would allow the user to change the time period, am I better spawning a new thread each time just in case it is set for 1 minute.

Any other advice would be helpful.

Comment
Watch Question

Most Valuable Expert 2012
Top Expert 2014

Commented:
Do you have to poll? Look into SqlDependency class

http://www.codeproject.com/KB/database/chatter.aspx

Author

Commented:
the problem I need to calculate based on the schedule when a task is next due to execute.
Most Valuable Expert 2012
Top Expert 2014

Commented:
Is that the polling schedule or the schedule of actual execution?

Author

Commented:
Each task has a schedule of when to execute, I will be checking the schedule constantly, if it is due I will be add a record to the execution table then updating the schedule next due date
Most Valuable Expert 2012
Top Expert 2014
Commented:
Even with an interval of one minute, you should be fine. But you can also force an interval value which is greater than or equal to say 5 minutes.