How to pass method in Recurring Job in Hangfire?

beginer
beginer
1512 Points
51 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: 284
Total Answered: 1
Total Marked As Answer: 0
Posted On: 04-May-2024 00:57

Share:   fb twitter linkedin
Answers
Brian
Brian
2362 Points
13 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