Răsfoiți Sursa

Patch for bug #61802 (Approved by miguel)

svn path=/trunk/mcs/; revision=31389
Geoff Norton 21 ani în urmă
părinte
comite
b287d431b5

+ 5 - 0
mcs/class/corlib/System.Collections/ChangeLog

@@ -1,3 +1,8 @@
+2004-07-21  Geoff Norton <[email protected]>
+
+        * Hashtable.cs: lock the SyncRoot when Cloning a Synchronized hashtable to avoid
+          a snapshot out of sync error.
+
 2004-07-21  Duncan Mak  <[email protected]>
 
 	* DictionaryBase.cs: Rename the dictionary field to hashtable,

+ 3 - 2
mcs/class/corlib/System.Collections/Hashtable.cs

@@ -1114,8 +1114,9 @@ namespace System.Collections {
 
 			public override object Clone ()
 			{
-				Hashtable ht = (Hashtable) host.Clone ();
-				return new SyncHashtable (ht);
+				lock(host.SyncRoot) {
+					return new SyncHashtable( (Hashtable) host.Clone () );
+				}
 			}
 
 		} // SyncHashtable