Registring a BackgroundService

Hi,
I would like to use IHostedService with SS DI, how can I register that correctly?

Thanks

This isn’t apart of ServiceStack, register it in ASP.NET Core’s Startup’s ConfigureServices() as shown in the docs.

Thanks. So I can’t really inject SS services into it. right?

Inject SS Services? No. If the AppHost is initialized you can execute Services via HostContext.AppHost.ExecuteService().

The problem is that HostContext.AppHost is null because BackgroundService.StartAsync is invoked earlier…

Any other solution for that?
Thanks

No the AppHost isn’t initialized & can’t be used before then. Call it at runtime after Startup when the App has initialized.