Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# windows service or just normal program? [duplicate]

Possible Duplicates:
windows service vs scheduled task
Windows Service Vs Simple Program

I'm trying to create a program that runs periodically (say every 5 minutes), or have the program running and have it execute the function within it (every 5 minutes).

The program is to obtain data from a database when it's executed and then write this to (for now) say info.txt file (no sensitive stuff is contained in here). each time it writes to the file it should overwrite the existing info within the file.

The program should also be started automatically at windows start up. (thus no need to login on the machine and to execute the .exe [if it's a normal program and not a service])

In between the periods that it executes the program would have nothing to do.

Therefore, should I run this program as a Windows Service, or should I use the Task Scheduler to periodically start the program to do this? My goal is for this program to run as smooth as possible without clogging up resources. (eg. it shouldn't need more than 5% of the cpu)

I hope my question was clear enough.

like image 852
Raskaroth Avatar asked Mar 30 '11 16:03

Raskaroth


1 Answers

I would go with application that is triggered by task scheduler. Only thing that you need to worry about is to run single instance of your application.

You can set task to run under specific user account and to run even if user is not logged on. There are number of events that can trigger task star like "Windows start", "System Idle"...

Other advantage is: If something crashes you can set task scheduler to send you an email or alert you in number of ways. You can control "exit code" of your application and signal to task scheduler what's going on and what to do.

There are a lot of positive features that task scheduler offers but not many people are using them.

like image 67
HABJAN Avatar answered Sep 23 '22 08:09

HABJAN