You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have installed Quartz v3.2.2, Quartz.Unity v3.2.0, Unity v5.11.7 in my MVC application. I have the following lines of code in my Global.asax file in the Application_Start event .
` ///////////////////////////////////////////////
var container = new UnityContainer();
container.RegisterType<ITestDependency, TestDependency>();
container.RegisterInstance<IUnityContainer>(container, InstanceLifetime.Singleton);
container.AddNewExtension<Quartz.Unity.QuartzUnityExtension>();
var schedulerFactory = container.Resolve<ISchedulerFactory>();
var scheduler = await schedulerFactory.GetScheduler(CancellationToken.None);
container.RegisterInstance<IScheduler>(scheduler, InstanceLifetime.Singleton);
var job = JobBuilder.Create<TestJob>()
.WithIdentity("TestJob")
.Build();
var trigger = TriggerBuilder.Create()
.WithIdentity("TestTrigger", "mygroup")
.WithCronSchedule("0 0/2 * * * ? *") //Fire every 2 minutes
.ForJob(job)
.StartNow()
.Build();
await scheduler.ScheduleJob(job, trigger);
await scheduler.Start();
`
My test job and test dependency is as follows:
`
public class TestJob : IJob
{
private readonly ITestDependency testDependency;
public TestJob(ITestDependency testDependency)
{
this.testDependency = testDependency;
}
//public TestJob()
//{
//}
public Task Execute(IJobExecutionContext context)
{
var task = Task.Run(() => {
testDependency.DoWork();
});
return task;
}
}
public interface ITestDependency
{
void DoWork();
}
public class TestDependency : ITestDependency
{
public void DoWork()
{
Thread.Sleep(10000);
}
}
`
The TestJob Job never fires. If I comment the TestJob constructor with parameter and uncomment the parameterless constructor, then the TestJob gets called. I tried out different things such as moving out the code to Startup.cs in the Configuration method but the issue remains.
The text was updated successfully, but these errors were encountered:
I have installed Quartz v3.2.2, Quartz.Unity v3.2.0, Unity v5.11.7 in my MVC application. I have the following lines of code in my Global.asax file in the Application_Start event .
` ///////////////////////////////////////////////
`
My test job and test dependency is as follows:
`
The TestJob Job never fires. If I comment the TestJob constructor with parameter and uncomment the parameterless constructor, then the TestJob gets called. I tried out different things such as moving out the code to Startup.cs in the Configuration method but the issue remains.
The text was updated successfully, but these errors were encountered: