Which is better of the two if I have to perform a cleanup task between 0800-1700hrs. The cleanup routine should be kicked in every 30 minutes.
I can put in a timer in a windows app which will fire every 30 minutes and check the time, if in the time frame, call cleanup routine or do the same thing as a windows service
or a windows scheduler which kicks in every 30 minutes and the app will check time and determine if its within the time frame, do cleanup and get off..
In the interests of keeping it simple, I would create a basic console application that performs the required cleanup. There would be no timer/scheduling code in this application.
I would then set up a windows schedule to run it at the required times/intervals. Also (as Fredrik says in the comments) you can easily run the console application manually if needed.
I wouldn't advise a creating a windows service unless you need the task to run when nobody is logged in, but then you also need to deal with running under different privileges from an interactive user. Also, a scheduled task can run when nobody is logged in anyway (thanks Rob).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With