I have a C# Application that does some maintenance tasks. It needs to run roughly every hour, although it's not too important if it's a bit off. And it has to run on a Win2003 Server with no one logged in.
Basically I wonder if I should write a Windows Service, and if yes, if Thread.Sleep() is a proper way to pause the Thread for an hour, or if there are better ways to make sure the Thread stays idle and does not put any server load? (aka. what is the most opposite of a Spinlock)
The alternative is the Windows Task Scheduler, but I am not sure if that is good for server use since a) i'd have to store the schedule in it rather than in my app.config, b) I cannot easily control the service through start/stop/restart and c) I do not know if the Credentials of the Windows User are as secure as when I enter it in the Service MMC Snapin.
What are your opinions? Is it possible and good to have an idle Service or would you recommend the task scheduler instead?