Fix thread-safety issues with enumerating ResourceManager. (#75054)
* Fix thread-safety issues with enumerating ResourceManager.
Concurrently enumerating a ResourceManager while also calling GetString()
and similar methods was prone to both transient errors and deadlock.
The transient errors were caused by RuntimeResourceSet calling internal
methods on ResourceReader that did not properly lock. Now, all exposed
methods on the Reader are thread-safe.
The deadlock was called by inconsistent lock ordering between
ResourceReader.ResourceEnumerator and RuntimeResourceSet which both lock
on the RuntimeResourceSet's cache and on the ResourceReader itself. Now,
the enumerator does not need to take both locks at the same time.
Fix #74052
Fix #74868
* Remove trailing whitespace
* Address feedback from https://github.com/dotnet/runtime/pull/75054
* Add comment in response to https://github.com/dotnet/runtime/pull/75054#issuecomment-
1317470280
* Implement feedback from https://github.com/dotnet/runtime/pull/75054