what is ConcurrentDictionary?

ConcurrentDictionary is one of five collection classes introduced in .NET 4.0. It exists in System.Collections.Concurrent namespace.ConcurrentDictionary is thread-safe collection class to store key/value pairs. ConcurrentDictionary can be used with multiple threads concurrently. Without ConcurrentDictionary class, if we have to use Dictionary class with multiple threads, then we have to use locks to provides thread-safety which is always error-prone.ConcurrentDictionary provides you an easy option. It internally manages the locking gives you an easy interface to add/update items. ConcurrentDictionary provides different methods as compared to Dictionary class. We can use AddOrUpdate, GetOrAdd ,TryAdd, TryUpdate, TryRemove, and TryGetValue to do CRUD operations on ConcurrentDictionary.

Comments

Post a Comment

Popular posts from this blog

Pagination of DataGrid in WPF using MVVM

Connect SQL Server Database to WPF Application and Perform CRUD Operations

Filter DataGrid and ListView in wpf using ICollectionView