internal JobWorker(JobWorkerBuilder builder) { this.jobWorkerBuilder = builder; this.source = new CancellationTokenSource(); this.logger = builder.LoggerFactory?.CreateLogger <JobWorker>(); this.jobHandler = jobWorkerBuilder.Handler(); this.autoCompletion = builder.AutoCompletionEnabled(); this.pollInterval = jobWorkerBuilder.PollInterval(); }
internal JobWorker(JobWorkerBuilder builder) { source = new CancellationTokenSource(); activator = new JobActivator(builder.Client); activeRequest = builder.Request; maxJobsActive = activeRequest.MaxJobsToActivate; pollInterval = builder.PollInterval(); jobClient = new JobClientWrapper(builder.JobClient); jobHandler = builder.Handler(); autoCompletion = builder.AutoCompletionEnabled(); }
internal JobWorker(JobWorkerBuilder builder) { this.jobWorkerBuilder = builder; this.source = new CancellationTokenSource(); this.logger = builder.LoggerFactory?.CreateLogger <JobWorker>(); this.jobHandler = jobWorkerBuilder.Handler(); this.autoCompletion = builder.AutoCompletionEnabled(); this.pollInterval = jobWorkerBuilder.PollInterval(); this.activateJobsCommand = jobWorkerBuilder.Command; this.maxJobsActive = jobWorkerBuilder.Command.Request.MaxJobsToActivate; this.thresholdJobsActivation = maxJobsActive * 0.6; }
/// <inheritdoc/> public void Dispose() { source.Cancel(); var pollInterval = jobWorkerBuilder.PollInterval(); // delay disposing, since poll and handler take some time to close Task.Delay(TimeSpan.FromMilliseconds(pollInterval.TotalMilliseconds * 2)) .ContinueWith(t => { logger?.LogError("Dispose source"); source.Dispose(); }); isRunning = false; }