-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Labels
Description
Hi @icsharp !
As long as there is no ExecuteAsync method support (hope yet) I tried to create a base class for my jobs.
public abstract class BaseRecurringJob : IRecurringJob
{
public void Execute(PerformContext context)
{
ExecuteAsync(context).GetAwaiter().GetResult();
}
protected virtual Task ExecuteAsync(PerformContext context) => Task.CompletedTask;
}
After that all my jobs can be used like so:
public class HealthCheckRecurringJob: BaseRecurringJob
There is a problem that a Hangfire JobActivator tries to create my base abstract class instead of using child class.
As I can see there is something wrong with this line:
option.JobType.GetMethod(nameof(IRecurringJob.Execute));
var addOrUpdate = Expression.Call(
typeof(RecurringJob),
nameof(RecurringJob.AddOrUpdate),
new Type[] { method.DeclaringType },
new Expression[]
{
Expression.Constant(recurringJobId),
Expression.Lambda(methodCall, x),
Expression.Constant(cron),
Expression.Constant(timeZone),
Expression.Constant(queue)
});
Could you please try to fix this issue?
Br, Alex