Exemple #1
0
        private async Task StartRunnerInternal(CancellationToken cancellationToken)
        {
            while (true)
            {
                var job = await GetReadyJob();

                if (job != null)
                {
                    _horariumLogger.Debug("Try to Run jobMetadata...");
#pragma warning disable 4014
                    Task.Run(() => _executorJob.Execute(job), cancellationToken);
#pragma warning restore 4014
                }

                if (cancellationToken.IsCancellationRequested)
                {
                    throw new TaskCanceledException();
                }

                if (!_settings.IntervalStartJob.Equals(TimeSpan.Zero))
                {
                    await Task.Delay(_settings.IntervalStartJob, cancellationToken);
                }
            }
        }
Exemple #2
0
        private async Task <bool> TryRunJob(CancellationToken cancellationToken, TimeSpan waitTime)
        {
            for (var i = 0; i < _settings.JobThrottleSettings.JobRetrievalAttempts; i++)
            {
                var job = await GetReadyJob();

                var isJobReady = job != null;

                if (isJobReady)
                {
                    _horariumLogger.Debug("Try to Run jobMetadata...");

                    var jobTask = Task.Run(() => _executorJob.Execute(job), CancellationToken.None);
                    _uncompletedTaskList.Add(jobTask);
                }

                if (cancellationToken.IsCancellationRequested)
                {
                    throw new TaskCanceledException();
                }

                if (isJobReady)
                {
                    return(true);
                }

                if (!waitTime.Equals(TimeSpan.Zero))
                {
                    await Task.Delay(waitTime, cancellationToken);
                }
            }

            return(false);
        }
Exemple #3
0
        private async Task StartRunnerInternal(CancellationToken cancellationToken)
        {
            while (true)
            {
                var job = await GetReadyJob();

                if (job != null)
                {
                    _horariumLogger.Debug("Try to Run jobMetadata...");

                    var jobTask = Task.Run(() => _executorJob.Execute(job), CancellationToken.None);
                    _uncompletedTaskList.Add(jobTask);
                }

                if (cancellationToken.IsCancellationRequested)
                {
                    throw new TaskCanceledException();
                }

                if (!_settings.IntervalStartJob.Equals(TimeSpan.Zero))
                {
                    await Task.Delay(_settings.IntervalStartJob, cancellationToken);
                }
            }
        }