Juni
Juni

Reputation: 95

Is it good to have windows service or console application?

I have a tasks table in my db. I want to read data from this table and run tasks. Which one is better whether to have it as windows service or a console application running. The server on which this will be run will not be shutdown

Upvotes: 7

Views: 8700

Answers (6)

TheDaveJay
TheDaveJay

Reputation: 783

You should look at: https://github.com/thedavejay/Self-Installing-Windows-Service

It allows you to debug as a console application and then install it as a windows service.

Upvotes: 0

jeroenh
jeroenh

Reputation: 26782

A running console app is not an option, as the others have stated.

If you just want the task run every x minutes the simplest option is a scheduled task using a console application.

A windows service has it's benefits, but is a little bit more complex to implement and deploy. However if your app needs to be 'always on' (e.g. need to react to external triggers, listen to message queue, ...), a windows service is the only option. As the others have said, the services infrastructure also provides more management capabilities, built-in integration with the event log, restart and failover options...

Upvotes: 4

Brian
Brian

Reputation: 2229

Windows service generally. Console app will need to be restarted if the server reboots while a windows service can start automatically.

Upvotes: 0

Dave New
Dave New

Reputation: 40032

You most likely want to use a windows service.

Benefits:

  • You can control the user (and the rights associated with this user account) which starts the process
  • An automatically started process means the desktop need to be on, not user logged, for the service to run
  • A policy on failure can be defined (try to restart n times run a specific program if fails)
  • A dependency can be defined (if you depend on other sevices)
  • You can wrap your script in an invisible window
  • You can easily start/stop/restart the script (net start <scriptname>)

Quoted from here: What is the benefit of developing the application as a windows service?

Upvotes: 8

Gerald Versluis
Gerald Versluis

Reputation: 34013

I would say; Windows Services.

In that case (among other things) you don't need a user to be logged in, you can configure it in a matter to restart automatically if it shuts down for some reason and you (could) have extensive rights throughout the system.

Upvotes: 0

Sergei Rogovtcev
Sergei Rogovtcev

Reputation: 5832

Windows service, because it does not require logged-in user.

Upvotes: 0

Related Questions