int dataSectionOffset;
long nameSectionOffset;
int resource_ver;
+ ResourceCacheItem[] cache;
+ object cache_lock = new object ();
// Constructors
[SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
reader.Close();
}
}
-
+
reader=null;
hashes=null;
infos=null;
typeNames=null;
+ cache = null;
}
internal sealed class ResourceEnumerator : IDictionaryEnumerator
private ResourceReader reader;
private int index = -1;
private bool finished;
- private ResourceCacheItem[] cache;
internal ResourceEnumerator(ResourceReader readerToEnumerate)
{
get { return index; }
}
- public DictionaryEntry Entry
- {
+ public DictionaryEntry Entry {
get {
if (reader.reader == null)
throw new InvalidOperationException("ResourceReader is closed.");
if (index < 0)
throw new InvalidOperationException("Enumeration has not started. Call MoveNext.");
- DictionaryEntry entry = new DictionaryEntry();
- entry.Key = Key;
- entry.Value = Value;
- return entry;
+ return new DictionaryEntry(Key, Value);
}
}
if (index < 0)
throw new InvalidOperationException("Enumeration has not started. Call MoveNext.");
- return cache [index].ResourceName;
+ return reader.cache [index].ResourceName;
}
}
throw new InvalidOperationException("ResourceReader is closed.");
if (index < 0)
throw new InvalidOperationException("Enumeration has not started. Call MoveNext.");
- return cache [index].ResourceValue;
+ return reader.cache [index].ResourceValue;
}
}
void FillCache ()
{
- if (reader.reader == null)
+ if (reader.cache != null)
return;
+
+ lock (reader.cache_lock) {
+ if (reader.cache != null)
+ return;
- ResourceCacheItem[] resources = new ResourceCacheItem [reader.resourceCount];
- reader.LoadResourceValues (resources);
- cache = resources;
+ ResourceCacheItem[] resources = new ResourceCacheItem [reader.resourceCount];
+ reader.LoadResourceValues (resources);
+ reader.cache = resources;
+ }
}
} // internal class ResourceEnumerator
} // public sealed class ResourceReader