I want to write a windows service which the user can schedule. i.e, the user can choose to run the service from 9:00 AM to 6 PM daily, or he could run it every night, starting from night 12 o clock at night to next day morning 6, etc. Is there any out of the box .NET API that will help me do this? I know I can do this using the Scheduled tasks, but is there any way to do this programmatically?
Share
My first response is to question why a service? But more importantly, the question would be why not use the powerful scheduler that is provided by the operating system?
That said, a windows service is pretty much just a thread that your application runs in. You could ship it in two parts, the first is the service itself which executes on a timer. The startup of the service could check a registry value to determine how often it’s supposed to execute.
The second part of the service would be a little windows app that allowed the user to set the schedule, and, of course, write it to the previously mentioned registry value.
There isn’t any sort of special API that you’d need.