Code Review and Testing

Oct 7, 2011 at 7:04 PM
I propose changing the contains method as follows...

        public bool Contains(T item)
        {
            bool doesContain = false;
 
            this.locker.EnterReadLock();
            Parallel.ForEach(this.items, (itemsItem, loop) =>
                {
                    if (itemsItem.Equals(item))
                    {
                        doesContain = true;
                        loop.Stop();
                    }
                });
            this.locker.ExitReadLock();
 
            return doesContain;
        }

This will remove the conflict of multiple parallel loop iterations changing the doesContain variable.