Used by Quartz.NET. There is a class

class SampleJob : IJob { public delegate void SampleNotification(string message); public event SampleNotification OnEvent; public void Execute(IJobExecutionContext context) { OnEvent(messageString); } } 

I create the scheduler:

 var job = JobBuilder.Create<SampleJob>().WithIdentity(jobName, groupName).Build(); var trigger = (ICronTrigger) TriggerBuilder.Create() .WithIdentity(triggerName, groupName) .WithCronSchedule(cronLine) .Build(); //добавляю job и trigger в Scheduler 

Is it possible to subscribe to the event inside Execute SampleJob from the place where it is added to the scheduler?

    1 answer 1

    In general, you can implement your factory IJob

     var _scheduler = new StdSchedulerFactory().GetScheduler(); _scheduler.JobFactory = new SchedulerServiceJobFactory(_kernel); 

    SchedulerServiceJobFactory is an implementation of the IJobFactory interface, and already in it you can subscribe, unsubscribe and generally do anything. instantiating an IJob object IJob done there ...