title: Why does ConcurrentDictionary.GetOrAdd(key, valueFactory) allow the valueFactory to be invoked twice?
body: <p>I am using a concurrent dictionary as a thread-safe static cache and noticed the following behavior:</p>
  
  <p>From <a href="https://docs.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2.getoradd" rel="noreferrer">the MSDN docs on GetOrAdd</a>:</p>
  
  <blockquote>
    <p>If you call GetOrAdd simultaneously on different threads,
    addValueFactory may be called multiple times, but its key/value pair
    might not be added to the dictionary for every call.</p>
  </blockquote>
  
  <p><strong>I would like to be able to guarantee that the factory is only called once. Is there any way to do this with the ConcurrentDictionary API without resorting to my own separate synchronization (e. g. locking inside valueFactory)?</strong></p>
  
  <p>My use case is that valueFactory is generating types inside a dynamic module so if two valueFactories for the same key run concurrently I hit:</p>
  
  <p><code>System.ArgumentException: Duplicate type name within an assembly.</code></p>