+2009-02-27 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+ * ResourceSet.cs: populating the resource should be locked because the
+ resourceset could be shared.
+
2009-01-24 Gonzalo Paniagua Javier <gonzalo@novell.com>
* ResourceManager.cs: don't throw every time we try to load a resource
#endif
protected IResourceReader Reader;
protected Hashtable Table;
+ bool resources_read;
[NonSerialized]
private bool disposed;
{
if (reader == null)
throw new ArgumentNullException ("reader");
+ Table = new Hashtable ();
Reader = reader;
}
[SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
public ResourceSet (Stream stream)
{
+ Table = new Hashtable ();
Reader = new ResourceReader (stream);
}
internal ResourceSet (IntPtrStream stream)
{
+ Table = new Hashtable ();
Reader = new ResourceReader (stream);
}
public ResourceSet (string fileName)
{
+ Table = new Hashtable ();
Reader = new ResourceReader (fileName);
}
#else
throw new InvalidOperationException ("ResourceSet is closed.");
#endif
- if (Table == null)
- ReadResources ();
+ ReadResources ();
return Table.GetEnumerator();
}
#else
throw new InvalidOperationException ("ResourceSet is closed.");
#endif
- if (Table == null)
- ReadResources ();
+ ReadResources ();
object o = Table [name];
if (o != null)
#else
throw new InvalidOperationException ("ResourceSet is closed.");
#endif
-
- IDictionaryEnumerator i = Reader.GetEnumerator();
-
- if (Table == null)
- Table = new Hashtable ();
- i.Reset ();
-
- while (i.MoveNext ())
- Table.Add (i.Key, i.Value);
+ if (resources_read)
+ return;
+
+ lock (Table) {
+ if (resources_read)
+ return;
+
+ IDictionaryEnumerator i = Reader.GetEnumerator();
+ i.Reset ();
+ while (i.MoveNext ())
+ Table.Add (i.Key, i.Value);
+ resources_read = true;
+ }
}
#if NET_2_0