Пример #1
0
        /// <summary>
        /// Stops jobs.
        /// Only jobs marked with "STOP" command will be acted on.
        /// ThreadMode="task" will use CancellationTokenSource.Cancel()
        /// Make sure the jobs implement CancellationToken.IsCancellationRequested check for throwing and clean up canceled job.
        /// ThreadMode="thread" will use Thread.Abort.
        /// No clean up is possible when thread is aborted.
        /// </summary>
        public async Task StopJobsAsync(bool isSync)
        {
            var jobIDs = isSync ? jobDAL.GetJobIdsByProcessAndCommand(workerProcessID, JobCommand.Stop) : await jobDAL.GetJobIdsByProcessAndCommandAsync(workerProcessID, JobCommand.Stop);

            if (isSync)
            {
                StopJobsAsync(jobIDs, isSync).GetAwaiter().GetResult();
            }
            else
            {
                await StopJobsAsync(jobIDs, isSync);
            }
        }