ReaderWriterLock synchronize access to a resource.
A ReaderWriterLock has better throughput than a Monitor, which is one-at-a-time lock. This works for a situation when a resource is changed rarely.
Let us see how to declare a ReaderWriter lock in C# −
static ReaderWriterLock r = new ReaderWriterLock();
The following are the properties of a ReaderWriter lock in C# −
|Sr.No.||Property & Description|
Gets a value indicating whether the current thread holds a reader lock.
Gets a value indicating whether the current thread holds a Writer lock.
Current sequence number
The following are some of the methods of ReaderWriter lock −
|Sr.No.||Method & Description|
Acquires a reader lock, using a TimeSpan value for the time-out.
Acquires a Writer lock, using a TimeSpan value for the time-out.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Type of the current instance
Lock Count decrements