Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Thread-safe access to static collection
- private static Dictionary<Type, List<PropertyInfo>> PropertyCache { get; set; }
- // I will do this
- PropertyCache.Add(typeof(string), new List<PropertyInfo>());
- PropertyCache.Remove(typeof(string));
- // I will never do this
- PropertyCache = new Dictionary<Type, List<PropertyInfo>>();
- lock(((ICollection)myObject).SyncRoot)
- {
- //Code that should be executed by only one concurrent thread
- //This is add/insert/remove/iterate/clear/etc.
- }
Add Comment
Please, Sign In to add comment