Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows App or Windows Service to run a periodically between 0800-1700

Tags:

c#

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..

like image 495
ltech Avatar asked Nov 30 '22 06:11

ltech


1 Answers

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).

like image 117
Ash Avatar answered Dec 05 '22 06:12

Ash