

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Use ReaderWriter Lock in C#
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 |
---|---|
1 | IsReaderLockHeld Gets a value indicating whether the current thread holds a reader lock. |
2 | IsWriterLockHeld Gets a value indicating whether the current thread holds a Writer lock. |
3 | WriterSeqNum Current sequence number |
The following are some of the methods of ReaderWriter lock −
Sr.No. | Method & Description |
---|---|
1 | AcquireReaderLock(TimeSpan) Acquires a reader lock, using a TimeSpan value for the time-out. |
2 | AcquireWriterLock(TimeSpan) Acquires a Writer lock, using a TimeSpan value for the time-out. |
3 | Equals(Object) Determines whether the specified object is equal to the current object.(Inherited from Object.) |
4 | GetHashCode() Default hash |
5 | GetType() Type of the current instance |
6 | ReleaseReaderLock() Lock Count decrements |
- Related Questions & Answers
- Object level lock vs Class level lock in Java?
- Transaction lock in MongoDB?
- Difference between Object level lock and Class level lock in Java
- Check if Caps Lock and Num Lock is on or off through Console in C#
- Defining user lock settings in SAP HANA
- How to lock multiple tables in MySQL?
- Lock down of SAP HANA system
- How to lock Screen Orientation programmatically in iOS?
- Lock & Key problem using Hash-map
- How to lock the Android device programmatically?
- An alternative invisible lock screen on android
- Checking transaction list waiting for lock-in SAP HANA
- What is the Python Global Interpreter Lock (GIL)
- What is the difference between Monitor and Lock in C#?
- How to debug Lock wait timeout exceeded on MySQL?