C# Dictionary Loop Enhancment
- by Toto
Hi,
I have a dictionary with around 1 milions items. I am constantly looping throw the dictionnary :
    public void DoAllJobs()
    {
            foreach (KeyValuePair<uint, BusinessObject> p in _dictionnary)
            {
                if(p.Value.MustDoJob)
                    p.Value.DoJob();
            }
    }
The execution is a bit long, around 600 ms, I would like to deacrese it. Here is the contraints :
   MustDoJob values mostly stay the same beetween two calls to DoAllJobs()
   60-70% of the MustDoJob  values == false
   From time to times MustDoJob change for 200 000 pairs.
   Some p.Value.DoJob() can not be computed at the same time (COM object call)
   Here, I do not need the key part of the _dictionnary objet but I really do need it somewhere else
I wanted to do the following :
     Parallelizes but I am not sure is going to be effective due to 4. 
     Sorts the dictionnary since 1. and 2. (and stop want I find the first MustDoJob == false)  but I am wondering what 3. would result in 
I did not implement any of the previous ideas since it could be a lot of job and I would like to investigate others options before. So...any ideas ?