Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hangfire call method in class

Tags:

hangfire

I want to convert QUARTZ jobs to hangfire

There I have a class with Execute method.

How to call this method in Hangfire. I try something like

public static string CRON_EXP = "0 30 1 ? * *";
RecurringJob.AddOrUpdate("CheckStudentAgeJob", () => CheckStudentAgeJob(), CRON_EXP);

class is

public class CheckStudentAgeJob {
    public void Execute()
    {
          //...
    }
}

but syntax is not correct. How can I do this?

like image 322
mbrc Avatar asked Jan 31 '26 14:01

mbrc


1 Answers

You are trying to call a class instead of a method. It should be:

public static string CRON_EXP = "0 30 1 ? * *";
RecurringJob.AddOrUpdate("CheckStudentAgeJob", 
                         () => new CheckStudentAgeJob().Execute(), CRON_EXP);
like image 191
GôTô Avatar answered Feb 03 '26 09:02

GôTô