A scheduled background job is to execute twice. Not sure why this is happening.
Schedule Job Code
-> var res = BackgroundJob.Enqueue(() => PickingUser(liRequestId));
Configuration
public void Configuration(IAppBuilder loIAppBuilder)
{
loIAppBuilder.UseHangfireAspNet(GetHangfireServers);
loIAppBuilder.UseHangfireDashboard();
HttpConfiguration loHttpConfiguration = new HttpConfiguration();
loHttpConfiguration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
ConfigureAuth(loIAppBuilder);
WebApiConfig.Register(loHttpConfiguration);
loIAppBuilder.UseWebApi(loHttpConfiguration);
}
private IEnumerable GetHangfireServers()
{
string lsConnectionString = string.Empty;
lsConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[“userContDB”].ConnectionString;
Hangfire.GlobalConfiguration.Configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(lsConnectionString, new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
UsePageLocksOnDequeue = true,
DisableGlobalLocks = true
});
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 1 });
yield return new BackgroundJobServer();
}
Some time it will start execution twice and update details twice.