System.Threading.ReaderWriterLock.WriterSeqNum Property

Gets the current sequence number.

Syntax

public int WriterSeqNum { get; }

Value

Documentation for this section has not yet been entered.

Remarks

The sequence number increases whenever a thread acquires the writer lock. You can save the sequence number and pass it to ReaderWriterLock.AnyWritersSince(int) at a later time, if you want to determine whether other threads have acquired the writer lock in the meantime.

You can use WriterSeqNum to improve application performance. For example, a thread might cache the information it obtains while holding a reader lock. After releasing and later reacquiring the lock, the thread can determine whether other threads have written to the resource by calling AnyWritersSince; if not, the cached information can be used. This technique is useful when reading the information protected by the lock is expensive; for example, running a database query.

The caller must be holding a reader lock or a writer lock in order for the sequence number to be useful.

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0