This template is intended to give you a starting point for writing long running services in. In this walkthrough we will create a worker and run it as a Windows Service. Preview Note: In our preview releases the worker template is in the same menu as the Web templates. We intend to place the Worker Service template directly inside the create new project wizard. In order to run as a Windows Service we need our worker to listen for start and stop signals from ServiceBase the. Public static IHostBuilder CreateHostBuilder(string args) => To do this we want to:Īdd the NuGet packageĪdd the UseServiceBaseLifetime call to the HostBuilder in our Program.cs public class Program NET type that exposes the Windows Service systems to. First, it checks whether or not the application is actually running as a Windows Service, if it isn’t then it noops which makes this method safe to be called when running locally or when running as a Windows Service. You don’t need to add guard clauses to it and can just run the app normally when not installed as a Windows Service.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |