Exemple #1
0
        /// <summary>
        /// Enqueues a job.
        /// </summary>
        /// <param name="job">The job.</param>
        public void Enqueue(Job job)
        {
            bool jobIsPending;
            this.queueLock.Enter();
            try
            {
                if (this.pendingJob != null)
                {
                    this.queue.Enqueue(job);
                    jobIsPending = false;
                }
                else
                {
                    this.pendingJob = job;
                    jobIsPending = true;
                }
            }
            finally
            {
                this.queueLock.Exit();
            }

            // Indicate to the job that this queue is pending. If this queue is the last to pend, enqueue for execution
            if (jobIsPending)
            {
                job.IncrementPendingQueues(this.FlaggedForRemoval);
            }
        }