2003-04-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sun, 27 Apr 2003 12:27:13 +0000 (12:27 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sun, 27 Apr 2003 12:27:13 +0000 (12:27 -0000)
* Enum.cs: fixed bug #41841.

svn path=/trunk/mcs/; revision=14041

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Enum.cs

index 3ab2d9a90b47f4425318c70b0101541646500432..8f7f9a1c9ae69df81fdff5b979fe6770e6541536 100644 (file)
@@ -1,3 +1,7 @@
+2003-04-27  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * Enum.cs: fixed bug #41841.
+
 2003-04-26  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * MonoType.cs:
index 185e93f3fc8cfb2b048195b77b9a5b218f388591..ce229438d3438093986e554dd720f8b8cda00648 100644 (file)
@@ -13,6 +13,7 @@
 using System.Collections;
 using System.Globalization;
 using System.Runtime.CompilerServices;
+using System.Threading;
 
 namespace System {
        internal struct MonoEnumInfo {
@@ -34,22 +35,24 @@ namespace System {
                internal static void GetInfo (Type enumType, out MonoEnumInfo info)
                {
                        if (cache == null) {
-                               cache = new Hashtable ();
-                       } else if (cache.ContainsKey (enumType)) {
-                               info = (MonoEnumInfo) cache [enumType];
-                               return;
-                       }
-
-                       lock (cache) {
+                               lock (typeof (MonoEnumInfo)) {
+                                       if (cache == null)
+                                               cache = new Hashtable ();
+                               }
+                               Monitor.Enter (cache);
+                       } else {
+                               Monitor.Enter (cache);
                                if (cache.ContainsKey (enumType)) {
                                        info = (MonoEnumInfo) cache [enumType];
+                                       Monitor.Exit (cache);
                                        return;
                                }
-
-                               get_enum_info (enumType, out info);
-                               Array.Sort (info.values, info.names);
-                               cache.Add (enumType, new MonoEnumInfo (info));
                        }
+
+                       get_enum_info (enumType, out info);
+                       Array.Sort (info.values, info.names);
+                       cache.Add (enumType, new MonoEnumInfo (info));
+                       Monitor.Exit (cache);
                }
        };