Windows Service or Scheduled Task, which one do we prefer?

后端 未结 10 1816
时光取名叫无心
时光取名叫无心 2020-12-16 12:07

If we need to write a program that works periodically, which way do we prefer? Writing a windows service or writing a console application which works as scheduled task?

10条回答
  •  离开以前
    2020-12-16 12:42

    "It depends", but I usually prefer scheduled tasks, for simplicity:

    • You do not need to add any boilerplate service code to you program.
    • Your program can be run from the command line for troubleshooting (you would have to use command line switches in your service program to accomplish this).

    If this is a more or less a one off, and something that you will install and controll yourself, a scheduled task is probably a good idea.

    For something that should have the feel of a finished product, and the customer should install themselves, I would go with a Windows Service.

    And the schedule is also an issue. The minimum schedule for a scheduled task is one minute. Anything below that, you either need to use a windows service, or build a loop into your job.

提交回复
热议问题