The ReaderWriterLock Slims down …. (in .NET 3.5)

I’ve been doing .NET 3.5 development for quite a few months, and didn’t realize until today that there’s a new “improved” ReaderWriterLock, called ReaderWriterLockSlim. (I never thought to look for a completely new class!).

From the documentation, it significantly improves the performance of uses of the old ReaderWriterLock, has simplified recursion rules, and simplifies changing lock state.  The bad news is that using the new class requires code changes (beyond just changing the type and the object instantiation). AcquireWriterLock becomes EnterWriterLock (or TryEnterWriterLock) for example. If you’re creating new code and need Reader-Writer lock behavior, use the new class.


Comments are closed.