internal void Remove(LoadFragment loadFragment)
 {
     if (loadFragment.PriorityQueueElement.Valid)
     {
         this.jobList.Remove(loadFragment.PriorityQueueElement);
     }
     this.totalLoad           -= loadFragment.PreviousLoad;
     loadFragment.PreviousLoad = 0;
     loadFragment.SetManagerInternal(null);
 }
        private void ThreadLoad_Operationable(ThreadLoad sender, EventArgs e)
        {
            this.threadLoad.Load = this.totalLoad;
            this.AddPendingLoadFragments();
            if (this.jobList.Count == 0)
            {
                return;
            }
            LoadFragment loadFragment = this.jobList.RemoveMin();

            try
            {
                loadFragment.InvokeOperationable();
            }
            finally
            {
                if (loadFragment.Manager == this)
                {
                    this.DoReserve(loadFragment);
                }
            }
        }
        private void DoReserve(LoadFragment loadFragment)
        {
            if (loadFragment.PriorityQueueElement.Valid)
            {
                return;
            }
            if (loadFragment.Manager == null)
            {
                loadFragment.SetManagerInternal(this);
                loadFragment.InvokeManagerAssign();
            }
            int previousLoad = loadFragment.PreviousLoad;
            int load         = loadFragment.Load;

            loadFragment.PreviousLoad = load;
            this.totalLoad           += load - previousLoad;
            if (load != 0)
            {
                loadFragment.PriorityQueueElement.Value    = loadFragment;
                loadFragment.PriorityQueueElement.Priority = loadFragment.Priority;
                this.jobList.Add(loadFragment.PriorityQueueElement);
                this.threadLoad.Load = this.totalLoad;
            }
        }
 internal void Reserve(LoadFragment loadFragment)
 {
     this.Add(loadFragment);
 }
 internal void Add(LoadFragment loadFragment)
 {
     this.newLoadFragmentList.Enqueue(loadFragment);
     this.threadLoad.Load = this.totalLoad + 1;
 }