public bool StopJob(string jobName) { lock (joblocker) { var jobcontent = Jobs.FirstOrDefault(x => x.JobName == jobName); if (jobcontent == null) { return(false); } jobcontent.OnInvoke = null; foreach (var a in jobcontent.Triggers) { try { Scheduler.PauseTrigger(a.Key); } // 停止触发器 catch { } try { Scheduler.UnscheduleJob(a.Key); } // 停止触发器 catch { } } try { Scheduler.DeleteJob(jobcontent.JobDetail.Key); }// 删除任务 catch { } Jobs.Remove(jobcontent); return(true); } }