How can I configure hangfire to excute only a instance?


I’m having problem with hangfire when I use recurringjob. My app has many jobs and sometimes a instance starts a job, same time that another instance still executing. I use InstancePerLifetimeScope, but when I use InstancePerBackgroundJob, hangfire throws a expection “Autofac.Core.DependencyResolutionException”. How can I solve this problem?


I’m using these attributes and from what I can tell I only have one instance running at a time now.

[AutomaticRetry(Attempts = 0, LogEvents = false, OnAttemptsExceeded = AttemptsExceededAction.Delete)]


thank you for your advice. It works for me.