title: Parallel ForEach and ConcurrentBag
body: <p>I've got a <code>ConcurrentBag</code> exposed to read/write operations inside a <code>Parallel.ForEach</code>.  Basically, I need to check for the existence of the object in the bag based on several properties and if there's no match, then I add it to the bag.  It's really, really slow.  Using a <code>List&lt;&gt;</code> without a lock is a fraction of the time.  What's wrong with this code?  Am I better of using a list locking with a <code>ReaderWriterLockSlim</code>?  I am processing about 1,000,000 objects here.</p>
  
  <pre><code>var bag = new ConcurrentBag&lt;Beneficiary&gt;();
  
  Parallel.ForEach(cx, _options, line =&gt;
  {
  if (!bag.Any(o =&gt;
         o.WinID == beneficiary.WinID &amp;&amp;
         o.ProductType == beneficiary.ProductType &amp;&amp;
         o.FirstName == beneficiary.FirstName &amp;&amp;
         o.LastName == beneficiary.LastName &amp;&amp;
         o.MiddleName == beneficiary.MiddleName))
  {
         bag.Add(beneficiary);    
  }
  }
  </code></pre>