Ejemplo n.º 1
0
        /// <summary>
        /// <see cref="IBackgroundTaskQueue.QueueAgentRun(AgentRunnerProcess)"></see>
        /// </summary>
        public void QueueAgentRun(AgentRunnerProcess workItem)
        {
            if (workItem == null)
            {
                throw new ArgumentNullException(nameof(workItem));
            }

            this.workItems.Enqueue(workItem);

            this.signal.Release();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// <see cref="IBackgroundTaskQueue.StopAsync(string)"></see>
        /// </summary>
        public Task StopAsync(string channel)
        {
            this.channelDeleted = channel;
            if (this.currentRunProcess != null && this.currentRunProcess.Channel.Equals(channel))
            {
                if (this.currentRunProcess.ProcessWrapper != null)
                {
                    this.currentRunProcess.ProcessWrapper.StopProcess();
                    this.currentRunProcess = null;
                }
            }

            this.workItems.Clear();

            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// <see cref="IBackgroundTaskQueue.DequeueAgentRunAsync(CancellationToken)"></see>
        /// </summary>
        public async Task <AgentRunnerProcess> DequeueAgentRunAsync(CancellationToken cancellationToken)
        {
            await this.signal.WaitAsync(cancellationToken);

            AgentRunnerProcess workItem;

            do
            {
                if (!this.workItems.TryDequeue(out workItem))
                {
                    return(null);
                }
            } while (workItem.Channel.Equals(this.channelDeleted));

            this.currentRunProcess = workItem;

            return(workItem);
        }