Base solution for your next web application
Open Closed

How to configure to use Worker Service (Windows Service) with ASPZERO #11213


User avatar
0
adamphones created

in .net 6 there is a new template as Worker Service that can be used to create Windows Services.

I followed the https://docs.microsoft.com/en-us/dotnet/core/extensions/windows-service to convert the Worker Service to Window Service.

Now I would like to migrate some of ASP ZERO background jobs( which runs in Application Pool) into Windows Service. In order to do that as ASP Boiler plate is moduler I have created a similar Module class in the project.

My question is how to combine those existing configurations with existing template so it would work best.

Where using (var bootstrapper = AbpBootstrapper.Create<MyModule>()) should go in the process?

Program.cs

    IHost host = Host.CreateDefaultBuilder(args)
         .UseWindowsService(options =>
      {
             options.ServiceName = ".NET Joke Service";
        })
        .ConfigureServices(services =>
     {
       services.AddHostedService<WindowsBackgroundService>();
     })
 .Build();

    await host.RunAsync(); 

2 Answer(s)