Exemple #1
0
        /// <summary>
        /// 删除任务
        /// </summary>
        /// <param name="crontabId">定时任务Id</param>
        public static void Remove(string crontabId)
        {
            JobKey jobKey = new JobKey(crontabId);

            if (_Scheduler.CheckExists(jobKey).Result)
            {
                _Scheduler.DeleteJob(jobKey).Wait();
            }

            using (ICrontabStore crontabStore = ResolveMediator.ResolveOptional <ICrontabStore>())
            {
                crontabStore?.Remove(crontabId);
            }
        }
Exemple #2
0
        /// <summary>
        /// 删除任务
        /// </summary>
        /// <param name="crontab">定时任务</param>
        public static void Remove <T>(T crontab) where T : class, ICrontab
        {
            JobKey jobKey = new JobKey(crontab.Id);

            if (_Scheduler.CheckExists(jobKey).Result)
            {
                _Scheduler.DeleteJob(jobKey).Wait();
            }

            using (ICrontabStore crontabStore = ResolveMediator.ResolveOptional <ICrontabStore>())
            {
                crontabStore?.Remove(crontab);
            }
        }