简体   繁体   中英

How I can Schedule Job in Quartz using Task<IScheduler> scheduler

While doing

  • scheduler.Shutdown(); ,
  • scheduler.ScheduleJob(job, trigger);
  • scheduler.DeleteJob(new JobKey(job, group));

It gives an error.

错误图片

private static RikyasScheduler instance = new RikyasScheduler();

    private Task<IScheduler> scheduler = null;
    public RikyasScheduler()
    {
        scheduler = StdSchedulerFactory.GetDefaultScheduler();
    }
    #endregion

    #region Methods
    public void StartScheduler()
    {
        try
        {
            scheduler.Start();
        }
        catch (Exception ex)
        { }
    }

    public void StopScheduler()
    {
        try
        {
            scheduler.Shutdown();
        }
        catch (Exception ex)
        { }
    }


    public void AddJob(IJobDetail job, ITrigger trigger)
    {
        try
        {
            scheduler.ScheduleJob(job, trigger);
        }
        catch (Exception ex)
        { }
    }

    public void RemoveJob(string job, string group)
    {
        try
        {
            scheduler.DeleteJob(new JobKey(job, group));
        }
        catch (Exception ex)
        { }
    }

Answer By : You should then use scheduler.Result to get the actual schedule instance. – Nilesh Shinde scheduler.Result.ScheduleJob(job, trigger);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM