1
// -----------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 // -----------------------------------------------------------------------
5 using System
.Collections
.Generic
;
8 using System
.Threading
;
10 namespace Microsoft
.Internal
12 internal sealed class Lock
: IDisposable
15 private ReaderWriterLockSlim _thisLock
= new ReaderWriterLockSlim(LockRecursionPolicy
.NoRecursion
);
16 private int _isDisposed
= 0;
17 public void EnterReadLock()
19 this._thisLock
.EnterReadLock();
22 public void EnterWriteLock()
24 this._thisLock
.EnterWriteLock();
27 public void ExitReadLock()
29 this._thisLock
.ExitReadLock();
32 public void ExitWriteLock()
34 this._thisLock
.ExitWriteLock();
39 if (Interlocked
.CompareExchange(ref this._isDisposed
, 1, 0) == 0)
41 this._thisLock
.Dispose();
46 // ReaderWriterLockSlim is not yet implemented on SilverLight
47 // Satisfies our requirements until it is implemented
48 object _thisLock
= new object();
54 public void EnterReadLock()
56 Monitor
.Enter(this._thisLock
);
59 public void EnterWriteLock()
61 Monitor
.Enter(this._thisLock
);
64 public void ExitReadLock()
66 Monitor
.Exit(this._thisLock
);
69 public void ExitWriteLock()
71 Monitor
.Exit(this._thisLock
);