Skip to content

Instantly share code, notes, and snippets.

@sskset
Last active July 11, 2020 15:40
Show Gist options
  • Save sskset/955b0892f48a57cd8bd6ff24ac585acb to your computer and use it in GitHub Desktop.
Save sskset/955b0892f48a57cd8bd6ff24ac585acb to your computer and use it in GitHub Desktop.
public void ConfigureServices(IServiceCollection services)
{
// Add Hangfire services.
services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(Configuration.GetConnectionString("Hangfire"), new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
DisableGlobalLocks = true
}));
// Add the processing server as IHostedService
services.AddHangfireServer();
services.AddControllers();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment