11 [HostProtection(
SecurityAction.LinkDemand, Synchronization =
true, ExternalThreading =
true)]
14 private IntPtr _hWriterEvent;
16 private IntPtr _hReaderEvent;
18 private IntPtr _hObjectHandle;
22 private int _dwULockID;
24 private int _dwLLockID;
26 private int _dwWriterID;
28 private int _dwWriterSeqNum;
30 private short _wWriterLevel;
37 [SecuritySafeCritical]
38 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
41 return PrivateGetIsReaderLockHeld();
50 [SecuritySafeCritical]
51 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
54 return PrivateGetIsWriterLockHeld();
62 [SecuritySafeCritical]
65 return PrivateGetWriterSeqNum();
70 [SecuritySafeCritical]
77 [SecuritySafeCritical]
85 private extern void AcquireReaderLockInternal(
int millisecondsTimeout);
92 [SecuritySafeCritical]
95 AcquireReaderLockInternal(millisecondsTimeout);
104 [SecuritySafeCritical]
108 if (num < -1 || num >
int.MaxValue)
112 AcquireReaderLockInternal((
int)num);
117 private extern void AcquireWriterLockInternal(
int millisecondsTimeout);
124 [SecuritySafeCritical]
127 AcquireWriterLockInternal(millisecondsTimeout);
136 [SecuritySafeCritical]
140 if (num < -1 || num >
int.MaxValue)
144 AcquireWriterLockInternal((
int)num);
149 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
150 private extern void ReleaseReaderLockInternal();
154 [SecuritySafeCritical]
155 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
158 ReleaseReaderLockInternal();
163 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
164 private extern void ReleaseWriterLockInternal();
168 [SecuritySafeCritical]
169 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
172 ReleaseWriterLockInternal();
181 [SecuritySafeCritical]
185 FCallUpgradeToWriterLock(ref result, millisecondsTimeout);
191 private extern void FCallUpgradeToWriterLock(ref
LockCookie result,
int millisecondsTimeout);
203 if (num < -1 || num >
int.MaxValue)
212 private extern void DowngradeFromWriterLockInternal(ref
LockCookie lockCookie);
218 [SecuritySafeCritical]
221 DowngradeFromWriterLockInternal(ref lockCookie);
226 [SecuritySafeCritical]
230 FCallReleaseLock(ref result);
236 private extern void FCallReleaseLock(ref
LockCookie result);
240 private extern void RestoreLockInternal(ref
LockCookie lockCookie);
245 [SecuritySafeCritical]
248 RestoreLockInternal(ref lockCookie);
253 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
254 private extern bool PrivateGetIsReaderLockHeld();
258 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
259 private extern bool PrivateGetIsWriterLockHeld();
263 private extern int PrivateGetWriterSeqNum();
270 [SecuritySafeCritical]
275 private extern void PrivateInitialize();
279 private extern void PrivateDestruct();
ReaderWriterLock()
Initializes a new instance of the T:System.Threading.ReaderWriterLock class.
bool AnyWritersSince(int seqNum)
Indicates whether the writer lock has been granted to any thread since the sequence number was obtain...
void ReleaseWriterLock()
Decrements the lock count on the writer lock.
void ReleaseReaderLock()
Decrements the lock count.
void AcquireReaderLock(int millisecondsTimeout)
Acquires a reader lock, using an T:System.Int32 value for the time-out.
Defines the lock that implements single-writer/multiple-reader semantics. This is a value type.
Ensures that all finalization code in derived classes is marked as critical.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
double TotalMilliseconds
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional milliseco...
Defines a lock that supports single writers and multiple readers.
Cer
Specifies a method's behavior when called within a constrained execution region.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
void RestoreLock(ref LockCookie lockCookie)
Restores the lock status of the thread to what it was before calling M:System.Threading....
LockCookie UpgradeToWriterLock(int millisecondsTimeout)
Upgrades a reader lock to the writer lock, using an Int32 value for the time-out.
void AcquireWriterLock(TimeSpan timeout)
Acquires the writer lock, using a T:System.TimeSpan value for the time-out.
A platform-specific type that is used to represent a pointer or a handle.
void AcquireWriterLock(int millisecondsTimeout)
Acquires the writer lock, using an T:System.Int32 value for the time-out.
MethodImplOptions
Defines the details of how a method is implemented.
void AcquireReaderLock(TimeSpan timeout)
Acquires a reader lock, using a T:System.TimeSpan value for the time-out.
bool IsWriterLockHeld
Gets a value indicating whether the current thread holds the writer lock.
LockCookie UpgradeToWriterLock(TimeSpan timeout)
Upgrades a reader lock to the writer lock, using a TimeSpan value for the time-out.
bool IsReaderLockHeld
Gets a value indicating whether the current thread holds a reader lock.
void DowngradeFromWriterLock(ref LockCookie lockCookie)
Restores the lock status of the thread to what it was before M:System.Threading.ReaderWriterLock....
int WriterSeqNum
Gets the current sequence number.
Represents a time interval.To browse the .NET Framework source code for this type,...
Consistency
Specifies a reliability contract.
LockCookie ReleaseLock()
Releases the lock, regardless of the number of times the thread acquired the lock.