Ran Sasportas
Ran Sasportas

Reputation: 2266

Scheduled task vs windows service

I need to decide which to use, what is more recommended to use? My requirements - run a daily task which should run every X minutes, and needs to be configurable via the codebase of the task so that I can deploy the task and the config change with it, It seems to me its a little more complicated on a schedule task because the intervalic run management is done outside of the code, which on windows service you control all the aspects of the intervalic run, what I don't like about the windows service is that you have a lot of code which is not related to the core logic and purpose of the task, and is related solely to the running of the task, which seems silly to me when I have the task scheduler interface built in my windows server which allows me complex configurations out of the box.

I am using team city as my build&deploy tool.

So I would like you're opinions with pros and cons and what you think is a best practice for this scenario

Upvotes: 1

Views: 635

Answers (1)

Shyamal Desai
Shyamal Desai

Reputation: 132

I would vote for creating a script that creates the required scheduled task(s) (using the scheduled task api). e.g. schtasks /create /tn ...

It has enough options to meet your requirements. It will be easy to maintain and deploy as it will not need recompiling on a change. Use a service if you have special requirements to manage different time zones or task scheduling logic.

Upvotes: 1

Related Questions