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.
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.
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.
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.
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With