-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for DI? #295
Comments
This is what I've done for D.I. (excuse the formatting, I copied and pasted from Github which messed it up): JobManager.JobStart += JobManager_JobStart;
JobManager.JobEnd += JobManager_JobEnd;
JobManager.JobException += JobManager_JobException;
JobManager.UseUtcTime();
JobManager.Initialize(new JobRegistry(serviceProvider)); using System;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using FluentScheduler;
using Jobs;
public class JobRegistry : Registry
{
public JobRegistry(IServiceProvider serviceProvider)
{
//Prevent concurrent jobs
NonReentrantAsDefault();
// Schedule PerformanceMonitor once per hour
Schedule(() => {
var rootScope = serviceProvider.GetAutofacRoot();
// Note, if you call 'return nestedScope.Resolve<PerformanceMonitor>();' then FluentScheduler will call Execute, but it won't Dispose any objects. Hence the using statement below and I'm manually calling Execute on the IJob implementation.
using(var nestedScope = rootScope.BeginLifetimeScope()) {
nestedScope.Resolve<PerformanceMonitor>().Execute();
}
}).ToRunNow().AndEvery(60).Minutes();
}} |
I'm using IMediatr for DI. Pretty standard setup as far as that is concerned. |
@t-ashraf why set this? cant we run parallel when its DI? |
@phoenixcoded20 - You can run in parallel when it's DI. This is just something we do because pretty much every one of our jobs uses our database and do not wish to see any of these: https://learn.microsoft.com/en-us/dotnet/api/system.data.entity.infrastructure.dbupdateconcurrencyexception?view=entity-framework-6.2.0 :) |
Hi,
According to the documentation there is no support for DI.
https://fluentscheduler.github.io/dependency-injection/
Any advice on what should be done here?
The text was updated successfully, but these errors were encountered: