Reputation: 701
What is the big difference between the worker service project template and the windows service project template and which is better to use?
When can I use a worker service & windows service?
Upvotes: 60
Views: 41120
Reputation: 1210
Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface. You can easily create services by creating an application that is installed as a service.
worker service is a .NET project built using a template which supplies a few useful features that turn a regular console application into something more powerful. A worker service runs on top of the concept of a host, which maintains the lifetime of the application. The host also makes available some familiar features, such as dependency injection, logging and configuration.
Upvotes: 6
Reputation: 2652
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.
That said, a Worker Service can also be configured to run as a Windows Service.
So from a C# perspective, a worker service is the same idea as a Task or a Thread. But it runs in its own address and memory space. Therefore, it won't crash just because the application crashes.
Upvotes: 37