Re: Windows Service or Console application



Hello Vadym,

services are there to run for a long time and before any user logged in.

IMO it would be far more simple to do this via console application

In many ways you may be correct in saying that it's simpler to use a console applications. But writing applications is often not about the simplest approach, but rather about satisfying criteria.

What you're saying first is important: services run when nobody is logged in. As the OP was talking about a "server machine", I assume that this could very well be an important feature.

In my experience, the best way to go is this:

* Pull out the core functionality of your service into a class library assembly

* Create a console application that utilizes the functionality in the library. This application can easily be debugged and tested, without the additional requirements and complications of the service.

* Create a Windows service that utilizes the functionality of the library as well. Deploy this, or maybe deploy both this and the console application - sometimes both can make sense.

The overhead of creating two different executables is typically minimal, if you do a good job of moving all actual functionality into the library assembly. Each of the executables usually ends up having just a very small number of lines of code, for example to parse command line options or to set up logging options.


Oliver Sturm
--
http://www.sturmnet.org/blog
.



Relevant Pages

  • Re: [RFC] [PATCH] Adding ctrl-o sysrq hack support to 8250 driver
    ... > The following patch will allow a user to use sysrq keys over a serial ... > console using the ctrl-o key sequence. ... This is similar to functionality ... > provided by the hvc console drivers on PPC boxes. ...
    (Linux-Kernel)
  • Writing a TSP: Assigning Users
    ... I've written a TSP and all functionality works 100% on the TAPI server. ... problem comes in when trying to get clients to utilize the devices. ... If I close the tapimgmt.msc console and re-open it, the assigned username ...
    (microsoft.public.win32.programmer.tapi)
  • Re: Text color in Windows console
    ... >>> If you need more functionality than that, try AWT or Swing. ... > Java is not a language well suited to interacting with the console. ...
    (comp.lang.java.programmer)
  • Re: The Wings of Honneamise [Blu-ray]
    ... and I'm not saying that you have to "get with the times" ... I ain't condemning gamers because of any fault of the GAMES. ... game console that you KNOW is going to be put away four years ...
    (rec.arts.anime.misc)
  • Re: Dragon Age: Origins gameplay vids
    ... will differ on the console versions? ... If not then the fact that they are writing it on a PC ends up being somewhat ... irrelevant if they will be writing the game to work optimally on the lowest ... He doesn't know what he's saying, he just gets paid for each copy sold or post solicited. ...
    (comp.sys.ibm.pc.games.rpg)