public override void Cancel(string jobId) { base.Cancel(jobId); if (!this.Repository.GetJobs().Any()) { CrossJobs.StopJobService(); } }
protected virtual async Task <JobRunResult> RunJob(JobInfo job, string batchName, CancellationToken cancelToken) { this.JobStarted?.Invoke(this, job); var result = default(JobRunResult); var cancel = false; try { this.LogJob(JobState.Start, job, "manual"); var service = CrossJobs.ResolveJob(job); await service .Run(job, cancelToken) .ConfigureAwait(false); if (!job.Repeat) { this.Cancel(job.Name); cancel = true; } this.LogJob(JobState.Finish, job, "manual"); result = new JobRunResult(job, null); } catch (Exception ex) { this.LogJob(JobState.Error, job, "manual", ex); result = new JobRunResult(job, ex); } finally { if (!cancel) { job.LastRunUtc = DateTime.UtcNow; this.Repository.Persist(job, true); } } this.JobFinished?.Invoke(this, result); return(result); }
public override void CancelAll() { base.CancelAll(); CrossJobs.StopJobService(); }
public override async Task Schedule(JobInfo jobInfo) { await base.Schedule(jobInfo); CrossJobs.StartJobService(); }