diff options
Diffstat (limited to 'mcs/class/corlib/System.Runtime.Remoting.Lifetime/Lease.cs')
-rw-r--r-- | mcs/class/corlib/System.Runtime.Remoting.Lifetime/Lease.cs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Lifetime/Lease.cs b/mcs/class/corlib/System.Runtime.Remoting.Lifetime/Lease.cs index 48a2f721072..bc6be38f12d 100644 --- a/mcs/class/corlib/System.Runtime.Remoting.Lifetime/Lease.cs +++ b/mcs/class/corlib/System.Runtime.Remoting.Lifetime/Lease.cs @@ -118,9 +118,15 @@ namespace System.Runtime.Remoting.Lifetime public void Register (ISponsor obj, TimeSpan renewalTime) { - lock (this) { - if (_sponsors == null) - _sponsors = new ArrayList(); + if (_sponsors == null)
+ { + lock (this) { + if (_sponsors == null) + _sponsors = new ArrayList(); + } + } + + lock (_sponsors.SyncRoot) { _sponsors.Add (obj); } @@ -137,8 +143,9 @@ namespace System.Runtime.Remoting.Lifetime public void Unregister (ISponsor obj) { - lock (this) { - if (_sponsors == null) return; + if (_sponsors == null) return; + + lock (_sponsors.SyncRoot) { _sponsors.Remove (obj); } } @@ -156,7 +163,7 @@ namespace System.Runtime.Remoting.Lifetime if (_sponsors != null) { _currentState = LeaseState.Renewing; - lock (this) { + lock (_sponsors.SyncRoot) { _renewingSponsors = new Queue (_sponsors); } CheckNextSponsor (); |