X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FSystem.ComponentModel%2FLicenseManager.cs;h=332e78f8b0606af2ee718fb49705395c9e3aff6b;hb=48d09aa40cba4b63e7282ed0f0492d6ff952779f;hp=77c0661308b4a5806ec848069e9d25a53da87a82;hpb=24f5ef2c44a90d1c26375389ab93bc982c9c0543;p=mono.git diff --git a/mcs/class/System/System.ComponentModel/LicenseManager.cs b/mcs/class/System/System.ComponentModel/LicenseManager.cs index 77c0661308b..332e78f8b06 100644 --- a/mcs/class/System/System.ComponentModel/LicenseManager.cs +++ b/mcs/class/System/System.ComponentModel/LicenseManager.cs @@ -36,8 +36,10 @@ namespace System.ComponentModel { public sealed class LicenseManager { - private static LicenseContext mycontext = null; - private static object contextLockUser = null; + static LicenseContext mycontext; + static object contextLockUser; + + static object lockObject = new object (); private LicenseManager () { @@ -45,7 +47,7 @@ namespace System.ComponentModel public static LicenseContext CurrentContext { get { - lock (typeof(LicenseManager)) { + lock (lockObject) { //Tests indicate a System.ComponentModel.Design.RuntimeLicenseContext should be returned. if (mycontext==null) mycontext = new Design.RuntimeLicenseContext(); @@ -53,7 +55,7 @@ namespace System.ComponentModel } } set { - lock (typeof(LicenseManager)) { + lock (lockObject) { if (contextLockUser==null) { mycontext = value; } else { @@ -80,17 +82,17 @@ namespace System.ComponentModel object[] args) { object newObject = null; - lock (typeof (LicenseManager)) { - object lockObject = new object (); + lock (lockObject) { + object contextUser = new object (); LicenseContext oldContext = CurrentContext; CurrentContext = creationContext; - LockContext (lockObject); + LockContext (contextUser); try { newObject = Activator.CreateInstance (type, args); } catch (Reflection.TargetInvocationException exception) { throw exception.InnerException; } finally { - UnlockContext (lockObject); + UnlockContext (contextUser); CurrentContext = oldContext; } } @@ -131,14 +133,14 @@ namespace System.ComponentModel public static void LockContext (object contextUser) { - lock (typeof (LicenseManager)) { + lock (lockObject) { contextLockUser = contextUser; } } public static void UnlockContext (object contextUser) { - lock (typeof(LicenseManager)) { + lock (lockObject) { //Ignore if we're not locked if (contextLockUser == null) return;