[asp.net] Fix for bug #685267. ClientScriptManager generates correct post-back event...
[mono.git] / mcs / class / System.Web / System.Web.UI / TemplateControl.cs
index 6dd55c0c8dea567882aa65165849e313a3d0460f..6480b008bd983488f7a684fb58121c89be6db3d4 100644 (file)
@@ -33,12 +33,15 @@ using System.Collections;
 using System.ComponentModel;
 using System.Reflection;
 using System.Security.Permissions;
+using System.Threading;
 using System.Web.Compilation;
 using System.Web.Util;
 using System.Xml;
 using System.IO;
 using System.Runtime.InteropServices;
 using System.Text;
+using System.Collections.Generic;
+using System.Collections.Concurrent;
 
 namespace System.Web.UI
 {
@@ -128,26 +131,16 @@ namespace System.Web.UI
                        public bool noParams;
                }
 
-               static Hashtable auto_event_info;
-               static object auto_event_info_monitor = new Object ();
+               static SplitOrderedList<Type, ArrayList> auto_event_info = new SplitOrderedList<Type, ArrayList> (EqualityComparer<Type>.Default);
 
                internal void WireupAutomaticEvents ()
                {
                        if (!SupportAutoEvents || !AutoEventWireup)
                                return;
 
-                       ArrayList events = null;
-
                        /* Avoid expensive reflection operations by computing the event info only once */
-                       lock (auto_event_info_monitor) {
-                               if (auto_event_info == null)
-                                       auto_event_info = new Hashtable ();
-                               events = (ArrayList)auto_event_info [GetType ()];
-                               if (events == null) {
-                                       events = CollectAutomaticEventInfo ();
-                                       auto_event_info [GetType ()] = events;
-                               }
-                       }
+                       Type type = GetType ();
+                       ArrayList events = auto_event_info.InsertOrGet ((uint)type.GetHashCode (), type, null, CollectAutomaticEventInfo);
 
                        for (int i = 0; i < events.Count; ++i) {
                                EvtInfo evinfo = (EvtInfo)events [i];