Creating a recurring job with interface specification

Hi Forum,

I am wondering if anyone knows how to create a recurring job that is based of interface specifications.

The implementation that I am trying to work with is as follows:

  • We have castle windsor handling the dependencies for us.
  • We wont to start a recurring job based on an interface specification so that when hangfire runs, castle windsor will give it the correct implementation details for that interface.

Effectively I suppose I’m looking for something similar to this:
RecurringJob.AddOrUpdate(() => IInterface.Method(), Cron.Daily)

So basically what we get there is saying that the recurring job must run a method from an interface but the actually method’s implementation will be provided when the job runs (by castle windsor).

Hope that all makes sense.

I found what I was looking for on this page:

http://docs.hangfire.io/en/latest/background-methods/passing-dependencies.html

Basically the code is:
RecurringJob.AddOrUpdate<IInterface>(x => x.Method(), Cron.Daily)

Hope this helps anyone else in the future if they are searching for keywords that I had in mind when asking the question :slight_smile: