The class looks as follows:
public static class CacheManager
{
private static Dictionary<string, object> cacheItems = new Dictionary<string, object>();
private static ReaderWriterLockSlim locker = new ReaderWriterLockSlim();
public static Dictionary<string, object> CacheItems
{
get
{
return cacheItems;
}
}
...
}
The ReaderWriterLockSlim locker object should be used as well.
The client looks as follows now:
foreach (KeyValuePair<string, object> dictItem in CacheManager.CacheItems)
{
...
}
Thank you in advance.
If you only need to iterate the contents, then frankly it isn’t really being used as a dictionary, but an iterator block and indexer might be used to hide the internal object: