Ejemplo n.º 1
0
        /// <summary>
        /// Cancels the job.
        /// </summary>
        /// <param name="jobStateId">The job state identifier.</param>
        public async Task CancelAsync(int jobStateId)
        {
            var jobState = await stateManager.FindByIdAsync(jobStateId).ConfigureAwait(true);

            if (jobState.Status == Status.Running)
            {
                managementStore.Cancel(jobState.JobId !);
                await stateManager.UpdateAsync(new JobStateUpdate { Id = jobStateId, Status = Status.Cancelling }).ConfigureAwait(true);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the state.
        /// </summary>
        /// <param name="update">The update.</param>
        /// <returns>
        /// True if the job should be aborted; otherwise false.
        /// </returns>
        protected async Task <bool> UpdateStateAsync(JobStateUpdate update)
        {
            _ = update ?? throw new ArgumentNullException(nameof(update));
            var jobState = await GetStateAsync(update.Id).ConfigureAwait(true);

            await stateManager.UpdateAsync(update).ConfigureAwait(true);

            var abortJob = jobState.Status != Status.Running && jobState.Status != Status.Resuming && jobState.Status != Status.Queued;

            return(abortJob);
        }