c# Programming Glossary: readerwriterlockslim
ReaderWriterLock vs lock{} http://stackoverflow.com/questions/2116957/readerwriterlock-vs-lock so it might be more efficient. If you are using .NET 3.5 ReaderWriterLockSlim is even faster. So if your shared resource is being read more.. resource is being read more often than being written use ReaderWriterLockSlim . A good example for using it is a file that you read very often..
ReaderWriterLockSlim vs. Monitor http://stackoverflow.com/questions/407238/readerwriterlockslim-vs-monitor vs. Monitor I have an IDictionary TKey TValue implementation.. For parallel insertions i locked the Add method with a ReaderWriterLockSlim locking only the individual sub dictionary public void Add TKey.. about 32 cpu usage and bad performance. So i replaced the ReaderWriterLockSlim by a Monitor i.e. the lock keyword . CPU usage was now at nearly..
Conditional compilation depending on the framework version in C# http://stackoverflow.com/questions/408908/conditional-compilation-depending-on-the-framework-version-in-c-sharp which allow something like #if CLR_AT_LEAST_3.5 use ReaderWriterLockSlim #else use ReaderWriterLock #endif or some other way to do this..
How to implement ConcurrentHashSet in .Net http://stackoverflow.com/questions/4306936/how-to-implement-concurrenthashset-in-net class ConcurrentHashSet T IDisposable private readonly ReaderWriterLockSlim _lock new ReaderWriterLockSlim LockRecursionPolicy.SupportsRecursion.. private readonly ReaderWriterLockSlim _lock new ReaderWriterLockSlim LockRecursionPolicy.SupportsRecursion private readonly HashSet..
Using FileSystemWatcher with multiple files http://stackoverflow.com/questions/6943908/using-filesystemwatcher-with-multiple-files public class Monitor private List string filePaths private ReaderWriterLockSlim rwlock private Timer processTimer public event EventHandler.. Monitor string path filePaths new List string rwlock new ReaderWriterLockSlim FileSystemWatcher watcher new FileSystemWatcher watcher.Filter.. Monitor IDisposable private List string filePaths private ReaderWriterLockSlim rwlock private Timer processTimer private string watchedPath..
|