O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

More Advanced Locks

Added in .NET 3.5 and .NET 4.0, respectively, the ReaderWriterLockSlim and SpinLock primitives are often useful, too. Their use is fairly specialized, so we’ll limit ourselves to a basic discussion.

ReaderWriterLock(Slim)

The essential problem of various concurrency and synchronization problems boils down to simultaneous reader and writer accesses on a shared resource. Often, the presence of multiple readers is allowed, while writers should be protected from one another to prevent harm. Therefore, the classic monitor-based lock is often too coarse-grained because it can’t differentiate from reader and writer accesses.

ReaderWriterLock and ReaderWriterLockSlim accommodate for such scenarios. The latter was introduced in .NET ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required