Breyta

Deila með


ReaderWriterLockSlim Class

Definition

Represents a lock that is used to manage access to a resource, allowing multiple threads for reading or exclusive access for writing.

public ref class ReaderWriterLockSlim : IDisposable
public class ReaderWriterLockSlim : IDisposable
type ReaderWriterLockSlim = class
    interface IDisposable
Public Class ReaderWriterLockSlim
Implements IDisposable
Inheritance
ReaderWriterLockSlim
Implements

Remarks

For more information about this API, see Supplemental API remarks for ReaderWriterLockSlim.

Constructors

ReaderWriterLockSlim()

Initializes a new instance of the ReaderWriterLockSlim class with default property values.

ReaderWriterLockSlim(LockRecursionPolicy)

Initializes a new instance of the ReaderWriterLockSlim class, specifying the lock recursion policy.

Properties

CurrentReadCount

Gets the total number of unique threads that have entered the lock in read mode.

IsReadLockHeld

Gets a value that indicates whether the current thread has entered the lock in read mode.

IsUpgradeableReadLockHeld

Gets a value that indicates whether the current thread has entered the lock in upgradeable mode.

IsWriteLockHeld

Gets a value that indicates whether the current thread has entered the lock in write mode.

RecursionPolicy

Gets a value that indicates the recursion policy for the current ReaderWriterLockSlim object.

RecursiveReadCount

Gets the number of times the current thread has entered the lock in read mode, as an indication of recursion.

RecursiveUpgradeCount

Gets the number of times the current thread has entered the lock in upgradeable mode, as an indication of recursion.

RecursiveWriteCount

Gets the number of times the current thread has entered the lock in write mode, as an indication of recursion.

WaitingReadCount

Gets the total number of threads that are waiting to enter the lock in read mode.

WaitingUpgradeCount

Gets the total number of threads that are waiting to enter the lock in upgradeable mode.

WaitingWriteCount

Gets the total number of threads that are waiting to enter the lock in write mode.

Methods

Dispose()

Releases all resources used by the current instance of the ReaderWriterLockSlim class.

EnterReadLock()

Tries to enter the lock in read mode.

EnterUpgradeableReadLock()

Tries to enter the lock in upgradeable mode.

EnterWriteLock()

Tries to enter the lock in write mode.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExitReadLock()

Reduces the recursion count for read mode, and exits read mode if the resulting count is 0 (zero).

ExitUpgradeableReadLock()

Reduces the recursion count for upgradeable mode, and exits upgradeable mode if the resulting count is 0 (zero).

ExitWriteLock()

Reduces the recursion count for write mode, and exits write mode if the resulting count is 0 (zero).

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)
TryEnterReadLock(Int32)

Tries to enter the lock in read mode, with an optional integer time-out.

TryEnterReadLock(TimeSpan)

Tries to enter the lock in read mode, with an optional time-out.

TryEnterUpgradeableReadLock(Int32)

Tries to enter the lock in upgradeable mode, with an optional time-out.

TryEnterUpgradeableReadLock(TimeSpan)

Tries to enter the lock in upgradeable mode, with an optional time-out.

TryEnterWriteLock(Int32)

Tries to enter the lock in write mode, with an optional time-out.

TryEnterWriteLock(TimeSpan)

Tries to enter the lock in write mode, with an optional time-out.

Applies to

Thread Safety

This type is thread safe.