How to use Hangfire with new worker in .NET core 3?

recurring
aspnetcore
Tags: #<Tag:0x00007f49973509e8> #<Tag:0x00007f49973508a8>

#1

When using new worker service

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddHangfireServer();
services.AddHangfire(config => config.UseSqlServerStorage(“connectionString”));
services.AddHostedService();
});

  1. How do I pass in BackgroundJobServerOptions?

  2. How can I queue all my recurring jobs in this setup? I can do it by calling GlobalConfiguration.Configuration.UseSqlServerStorage and RecurringJob.AddOrUpdate but I’d like to avoid calling static methods. Can it be done?