Name
ReaderWriterLock
Synopsis
This class defines a lock that allows
multiple readers, but only one writer. A thread can acquire a lock
by calling AcquireReaderLock()
or AcquireWriterLock()
. ReleaseReaderLock()
and ReleaseWriterLock()
release the specific locks.
Calling ReleaseReaderLock()
on a writer lock
releases both the writer lock and the reader lock. However,
calling ReleaseWriterLock()
on a reader lock
throws a System.ApplicationException
.
ReleaseLock()
causes any lock to be released,
but it returns a LockCookie
, which represents
the type of lock that RestoreLock()
can use to
obtain the same lock. UpgradeToWriterLock()
upgrades a reader lock to a writer lock and returns a LockCookie
representing the original reader
lock. Pass that cookie to DowngradeFromWriterLock()
to restore the
original reader lock.
Public NotInheritable Class ReaderWriterLock ' Public Constructors Public Sub New() ' Public Instance Properties Public ReadOnly Property IsReaderLockHeld As Boolean Public ReadOnly Property IsWriterLockHeld As Boolean Public ReadOnly Property WriterSeqNum As Integer ' Public Instance Methods Public Sub AcquireReaderLock( ByVal millisecondsTimeout As Integer) Public Sub AcquireReaderLock( ByVal timeout As TimeSpan) Public Sub AcquireWriterLock( ByVal millisecondsTimeout As Integer) Public Sub AcquireWriterLock( ByVal timeout As TimeSpan) Public Function AnyWritersSince( ByVal seqNum As Integer) As Boolean Public Sub DowngradeFromWriterLock( ByRef lockCookie As LockCookie) Public ...
Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.