-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Hi,
I would like to to use a service with a scheduled job
I tried this, but this error occour ..
: 'The request lifetime scope cannot be created because the HttpContext is not available.'
How I have to configure it ?
public class EmailJobScheduler
{
public void Start()
{
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
IJobDetail job = JobBuilder.Create<MyJob>().Build();
ITrigger trigger = TriggerBuilder.Create()
.WithSimpleSchedule(t =>
t.WithIntervalInSeconds(60)
.RepeatForever()
)
.Build();
scheduler.ScheduleJob(job, trigger);
scheduler.Start();
}
}
public class MyJob : IJob
{
public async void Execute(IJobExecutionContext context)
{
// How can call the service ?
var projectService = DependencyResolver.Current.GetService<IProjectService>(); // ERRROR
}
}
Metadata
Metadata
Assignees
Labels
No labels