如何使用Task <ischeduler>计划程序在Quartz中计划作业

时间:2019-01-03 06:41:34

标签: c# quartz-scheduler quartz

在做

  • scheduler.Shutdown(); ,
  • scheduler.ScheduleJob(作业,触发器);
  • scheduler.DeleteJob(new JobKey(job,group));

出现错误。

Error image

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)
        { }
    }

1 个答案:

答案 0 :(得分:0)

回答者:然后,您应该使用scheduler.Result获取实际的调度实例。 – Nilesh Shinde scheduler.Result.ScheduleJob(作业,触发器);