I need to write some .NET code that runs on a regular interval to check for “unprocessed” items in a table in the database, processes them, and then writes back to the database that they are processed. We’ll probably set it up to run every minute.
How can I set up in the component in a Windows Server environment so that the code executes on a periodic basis?
Use System.Timers.Timer in your windows service.
You can have such a code (from MSDN) in your windows service OnStart event :
If the interval is not frequent for example if it runs daily also consider using Windows Task Scheduler. It can run your application for the given interval (note if that interval is not so frequent).