Base solution for your next web application
Open Closed

Register recurrent Jobs in PostInitialize method #6476


User avatar
0
firnas created

Hi,

I have a to register a hangfire recurrent job in the PostInitialize method in the module. The job class constructor should be resolved by dependancy injection. I have used the following code to register the reccurent job in the module.

JobStorage.Current = new SqlServerStorage(_appConfiguration.GetConnectionString("Default")); RecurringJob.AddOrUpdate<ISendNotificationJob>(x => x.SendDeviceUnlockNotification(), Cron.MinuteInterval(10));

How ever when the SendDeviceUnlockNotification method is called it throws a object disposed exception. Can anyone please help me on this.

public SendNotificationJob(IRepository&lt;Payment> paymentRepository

, IPasstimeDomainService passtimeDomainService , IAppCentre appCentre , UserManager userManager) { _paymentRepository = paymentRepository; _passtimeDomainService = passtimeDomainService; _appCentre = appCentre; _userManager = userManager;

    }

2 Answer(s)