Beispiel #1
0
        /// <summary>
        /// This method will remove a job from the collection and flag it as an error.
        /// </summary>
        /// <param name="errorJob">THe job to remove.</param>
        protected virtual void RemoveErrorJob(JobHolder errorJob)
        {
            lock (this)
            {
                Guid? errorID = errorJob.ID;

                while (errorID.HasValue && WorkTable.Contains(errorID.Value))
                {
                    //Add the ID to the error list.
                    errorList.Add(errorID.Value);
                    Interlocked.Increment(ref errorCount);

                    try
                    {
                        //Get the error job, this is used to determine the dependency relationships.
                        errorJob = WorkTable[errorID.Value] as JobHolder;

                        //Remove the job from the collection
                        WorkTable.Remove(errorID.Value);
                        //Set the counters
                        Interlocked.Decrement(ref jobRequests);

                        //Does this job have dependencies? If not, then quit.
                        if (errorJob.DependencyID == null)
                            break;
                        //Is there a next job? If not then quit.
                        if (!errorJob.NextJob.HasValue)
                            break;

                        errorID = errorJob.NextJob.Value;
                    }
                    finally
                    {
                        if (errorJob != null)
                            errorJob.Reset();
                    }
                }
            }
        }