title: Quartz Scheduler's job fired but JobListener not picking up event?
body: <p>I have been struggling to make this work for a couple of days now. I am attempting to use the quartz scheduler to fire an event on my main form, from which a method can be called. Code on my main form is as follows:</p>
  
  <pre><code>void StartSchedule()
  {
      string AuctionTime = "0 0 0 ? * MON-FRI *";
  
      JobKey jobkey = new JobKey("Auction", "G");
  
      IJobDetail job = JobBuilder.Create&lt;AuctionJob&gt;()
                                  .WithIdentity(jobkey)
                                  .Build();
  
      CronScheduleBuilder csb = CronScheduleBuilder.CronSchedule(new CronExpression(AuctionTime)).InTimeZone(TimeZoneInfo.Local);
  
      ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create()
                                                          .WithIdentity("Auction-Trigger", "G")
                                                          .WithSchedule(csb)
                                                          .Build();
  
      // Create listener
      JobListener auctionListener = new JobListener();
      auctionListener.JobExecutedHandler += new EventHandler(SendAuctionOrders);
      IMatcher&lt;JobKey&gt; matcher = KeyMatcher&lt;JobKey&gt;.KeyEquals(jobkey);
      _scheduler.ListenerManager.AddJobListener(auctionlistener, matcher);
  
      // Add to scheduler
      DateTimeOffset ft = _scheduler.ScheduleJob(job, trigger);
  
      LogEvent(job.Key + " scheduled at: " + ft.ToLocalTime());
  
      jobkey = new JobKey("Auction2", "G");
  
      IJobDetail job = JobBuilder.Create&lt;AuctionJob&gt;()
                                  .WithIdentity(jobkey)
                                  .Build();
  
      csb = CronScheduleBuilder.CronSchedule(new CronExpression(AuctionTime)).InTimeZone(TimeZoneInfo.Local);
  
      ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create()
                                                          .WithIdentity("Auction-Trigger", "G")
                                                          .WithSchedule(csb)
                                                          .Build();
  
      // Create listener
      JobListener auction2Listener = new JobListener();
      auction2Listener.JobExecutedHandler += new EventHandler(SendAuctionOrders);
      IMatcher&lt;JobKey&gt; matcher = KeyMatcher&lt;JobKey&gt;.KeyEquals(jobkey);
      _scheduler.ListenerManager.AddJobListener(auction2listener, matcher);
  
      // Add to scheduler
      ft = _scheduler.ScheduleJob(job, trigger);
  
      LogEvent(job.Key + " scheduled at: " + ft.ToLocalTime());
  
      _scheduler.Start();
  }
  
  void SendAuctionOrders()
  {
      // Do something
  }
  </code></pre>
  
  <p>AuctionJob class looks like this:</p>
  
  <pre><code>public class AuctionJob : IJob
  {
      public void Execute(IJobExecutionContext context)
      {
          // Empty
          Console.WriteLine("auction exec");
      }
  }
  </code></pre>
  
  <p>While the job listener looks like this:</p>
  
  <pre><code>public class JobListener : IJobListener
  {
      private static readonly ILog logger = LogManager.GetLogger(typeof(JobListener));
  
      public event EventHandler JobExecutedHandler;
  
      public void JobExecutionVetoed(IJobExecutionContext context)
      {
          logger.Info("JobExecutionVetoed");
      }
  
      public void JobToBeExecuted(IJobExecutionContext context)
      {
          logger.Info("JobToBeExecuted");
      }
  
      public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
      {
          // Raise the event on executed
          OnJobExecuted(EventArgs.Empty);
  
          logger.Info("JobWasExecuted");
      }
  
      public string Name
      {
          get
          {
              return "JobListener";
          }
      }
  
      // Event raiser
      protected virtual void OnJobExecuted(EventArgs args)
      {
          // This code will prevent IllegalThreadContext exceptions
          EventHandler jobExecHandler = JobExecutedHandler;
  
          if (jobExecHandler != null)
          {
              ISynchronizeInvoke target = jobExecHandler.Target as ISynchronizeInvoke;
  
              if (target != null &amp;&amp; target.InvokeRequired)
              {
                  target.Invoke(jobExecHandler, new object[] { this, args });
              }
              else
              {
                  jobExecHandler(this, args);
              }
          }
      }
  }
  </code></pre>
  
  <p>When the job is triggered, the job was executed (console prints "auction exec") but job listener's JobWasExecuted does not pick it up. Could anyone help me with this? </p>
  
  <p>Additional questions: is there another way to call the main form's method? Also, would the job listener class persist through the entire application's (which in theory will not be closed). Thanks.</p>