On all examples there is not a single mention where is the best place to put my RecurringJob.AddOrUpdate.
Is that the Startup class?
Cheers.
On all examples there is not a single mention where is the best place to put my RecurringJob.AddOrUpdate.
Is that the Startup class?
Cheers.
Bump. I’d like to know also!
Startup works fine. but you can also place it in a controller action. whatever fits your needs
I called an initialization method from within startup:
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
Hangfire.ConfigureHangfire(app);
Hangfire.InitializeJobs();
}
}
Here is my HangFire class that I keep in App_Start:
public class Hangfire
{
public static void ConfigureHangfire(IAppBuilder app)
{
app.UseHangfire(config =>
{
config.UseSqlServerStorage("HangFireDB");
config.UseServer();
config.UseAuthorizationFilters(); //allow all users
});
}
public static void InitializeJobs()
{
RecurringJob.AddOrUpdate<HCIAPILib.AccountStatusJob>(j => j.Execute(), "0 23,19 * * *");
//RecurringJob.AddOrUpdate<HCIAPILib.AccountStatusJob>(j => j.Execute(), "* * * * *");
}
}