Windows App or Windows Service for periodic startup between 0800-1700

Which is better than the two if I need to complete a cleaning task between 0800-1700hrs. The cleaning procedure needs to be kicked every 30 minutes.

I can put a timer in a Windows application that will run every 30 minutes and check the time, if during a period of time, call the cleaning procedure or do the same as the Windows service

or a window scheduler that starts every 30 minutes, and the application checks the time and determines whether it will clear and exit over a period of time.

+4
source share
4 answers

In the interest of simply storing it, I would create a basic console application that performs the necessary cleanup. There will be no timer / scheduling code in this application.

I would set a window schedule to run it at the required times / intervals. Also (as Fredrick says in the comments), you can easily launch the console application manually if necessary.

I would not advise creating a Windows service if you do not need a task to start when no one is logged in, but then you also need to deal with starting under different privileges from an interactive user. In addition, a scheduled task can be executed when no one is logged in anyway (thanks Rob).

+19
source

You should take a look at the Quartz Enterprise Scheduler (open source) for .NET. You will find it on the Spring.NET website.

Personally, I think that creating a Windows service using the Quartz Enterprise Scheduler will be a neat way to implement what you requested and be independent of the window scheduler. At my company, window manager is disabled on every computer, including servers, as some viruses use it to spread.

+2
source

Your trade-offs:

  • Windows application. It requires that someone logs in and the application works.

  • Console application with Windows Scheduler. It takes someone to log in.

  • Windows service If you do not need access to the desktop of logged-in users, and you need to run it, whether someone was logged in or not, then this is the only option.

+1
source

What everyone else said.

The only caveat is that you need to control the execution time of the task through some type of interface (business operators want it to start from 0700, for example, or if they wanted to disable the task). In this case, you can manipulate the task scheduler programmatically through Power Shell or check the checkbox to make sure that it will be launched.

0
source

Source: https://habr.com/ru/post/1300419/


All Articles