If you make a check like this, then you might still end up with an exception regarding duplicate keys, because it is possible that 2 threads both do the `TryGetValue` and don't get a value back, then the first thread takes the lock and the second one must wait, then the first one adds the retrieved types to the collection and the second thread takes the lock and is going to add the same key to the collection which will throw an exception. If you do this like that, then you should test again for existence of the key inside the lock.

The same logic then needs to be applied to the `catch` section as well, so to prevent duplication of code (and taking a negligible performance hit which is not that bad since it is executed mostly during Glimpse Initialization code which runs serialized) I would take a lock on the `dictionary` right a the start of the method.

Maybe renamed it to `typesByAssembly` because dictionary is not that descriptive :wink:

You could also add the `[System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.Synchronized)]` attribute to the `RetrieveTypes` method, but I don't like locking on a `Type` so locking on the private `dictionary` is better.