How to pass method in Recurring Job in Hangfire?

beginer
beginer
1576 Points
53 Posts

I'm try to call method as:

RecurringJob.AddOrUpdate<IAccount>("RecurringJob.UpdateUserActivity", x => x.MigrateUserActivityUpdate(), Cron.Daily(10, 30));

Where

public interface IAccount
{
  void MigrateUserActivityUpdate();
}

But it's throwing error:

System.MissingMethodException: Cannot create an instance of an interface.

 

Views: 504
Total Answered: 1
Total Marked As Answer: 0
Posted On: 04-May-2024 00:57

Share:   fb twitter linkedin
Answers
Brian
Brian
2416 Points
14 Posts
         

Hangfire uses the JobActivator class to instantiate the target types before invoking instance methods. You can override its behavior to perform more complex logic on a type instantiation.

Here is link: https://docs.hangfire.io/en/latest/background-methods/using-ioc-containers.html

 

Posted On: 07-May-2024 22:13
 Log In to Chat