GetReadLock/GetWriteLock creates new object each time used


GetReadLock() and GetWriteLock both create a new object each time they are used. Instead, each one needs to be allocated only once (one object for GetReadLock() and one for GetWriteLock()).
Then when GetReadLock() is called, LockForReading() is internally called to start read locking. Then the IDisposable object associated with read locking is returned. When Dispose() is called on that object, UnlockForReading() is called to stop read locking.
And likewise with write locking. Incrementing and decrementing an integer shouldn't be necessary, but for debug mode only, it may come in handy.
Closed Sep 20, 2010 at 9:51 PM by TamusJRoyce
Fixed. GetReadLock() and GetWriteLock() each have a LockObject associated with them which gets allocated only once.LockObject.GetLock() starts locking, and Dispose stops the locking that was started.


TamusJRoyce wrote Sep 20, 2010 at 9:50 PM


wrote Sep 20, 2010 at 9:51 PM

wrote Feb 12, 2013 at 10:43 PM

wrote May 15, 2013 at 1:12 AM