Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Topshelf vs sc.exe vs Windows Service project type

As in title I would like to ask what is difference between using these possibilities of hosting my code on Windows Service. As far as I can see, all three allow me to create exe which will be installed as a service.

like image 766
user1121956 Avatar asked Dec 02 '12 17:12

user1121956


People also ask

What is topshelf used for?

Topshelf is a framework for hosting services written using the . NET framework. The creation of services is simplified, allowing developers to create a simple console application that can be installed as a service using Topshelf.

What is the difference between Windows service and worker service?

Both are real services. Windows Services have existed for over 20 years. They start most often at system startup and run permanently. A Worker Service is also a real process, but is intended as a background service for a front-end application; it starts with the application and stops with the application.

Does topshelf work with .NET core?

Topshelf is a . NET Standard library that takes a tonne of the hassle out of creating Windows Services in both . NET Framework and . NET Core.


2 Answers

Windows Services are special application types that respond to service control messages like Start, Stop, Pause, Continue etc.

While it is true that you can use something like sc.exe to turn any kind of process into a service, those processes will not handle the previously mentioned control messages. What you will commonly find is you'll be able to start a process but not stop it etc.

What I tend to do is abstract my services out (I think Topshelf does this), have a service library that can be loaded by a native Windows Service application or a console application so that I can have the best of both worlds (usually debugging under console).

like image 64
Lloyd Avatar answered Oct 17 '22 02:10

Lloyd


Topshelf is my preference because it allows you to get the best of both worlds a service and a console application. Using sc.exe allows you to execute any console application as a service, but the exe doesn't interact as a service itself. Developing a Windows Services directly let's you have a service and interact as one with Windows, but it isn't easy to debug or run as a normal console application. Topshelf allows you to ge the best of both running as a Service and running as a normal console application.

like image 26
kenny Avatar answered Oct 17 '22 01:10

kenny