Hello,
I have setting up a simple job activator like that :
public class HangfireJobActivator : Hangfire.JobActivator
{
private readonly IServiceProvider _serviceProvider;
public HangfireJobActivator(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public override object ActivateJob(Type type)
{
return _serviceProvider.GetService(type);
}
}
And set it in my Startup.cs like that :
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
{
GlobalConfiguration.Configuration.UseActivator(new HangfireServiceActivator(serviceProvider));
app.UseHangfireDashboard();
app.UseHangfireServer();
...
}
But when I run my projet in debug and trigger a recurringjob, it never use my customer job activator and instantiate new class…
My recurring job
RecurringJob.AddOrUpdate<MailboxDatabasesManager>("HE_RefreshDBEval", (x) => x.RefreshDatabaseEval(), Cron.MinuteInterval(30));
So, I can’t manage the retriving of “MailboxDatabasesManager” in my custom activator.
It’s same with a simple BackgroundJob.Enqueue((x) => x.func());
How to fix that?
Thx