title: When Iterating Over ConcurrentDictionary and only reading, is ConcurrentDictionary locked?
body: <ol>
  <li>I have a ConcurrrentDictionary created as an application object in my web app. and it is shared among sessions.  (Basically serves as a repository.)</li>
  <li>At times a new item is added to the dictionary by any available session.</li>
  </ol>
  
  <p><strong>Allow Admin View Only</strong></p>
  
  <p>Now, I want to allow an admin to list all the values in the dictionary, but the <em>admin will not add or remove items</em>, instead I will only provide a way for the admin to see the items via a read of the collection by iterating through the items.</p>
  
  <p><strong>(Pseudo)Code would look something like this</strong>:</p>
  
  <pre><code>foreach (var e in EmployeeCache.Instance.AllEmployees)
  {
       Console.WriteLine(e.Key);
  }
  </code></pre>
  
  <p><strong>My question is this:</strong></p>
  
  <p>If I iterate through the items does the ConcurrentDictionary get locked while it is being read from? In other words, is the ConcurrentDictionary locked so that other sessions would be unable to add or remove while the admin code is simply iterating through the ConcurrentDictionary?</p>
  
  <p><strong>If Not Locked, Can You Explain</strong></p>
  
  <p>If you believe it is not locked, can you give a quick summary of how it does this?
  For example, does it create a copy of the ConcurrentDictionary for the read-only action and then allow the read iterations to run -- understanding that concurrent changes to the real dictionary will not be seen?  </p>
  
  <p><strong>What I'm Trying To Determine</strong></p>
  
  <p>I'm trying to understand the impact of providing a ConcurrentDictionary viewer which could be refreshed often by an Admin.  I.E. If they refreshed it often enough could it impact the performance of the web app. as sessions are waiting for the object to unlock so they can add/remove items?</p>