daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Aug 14th, 2018 55 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. Thread-safe access to static collection
  2. private static Dictionary<Type, List<PropertyInfo>> PropertyCache { get; set; }
  3.    
  4. // I will do this
  5. PropertyCache.Add(typeof(string), new List<PropertyInfo>());
  6. PropertyCache.Remove(typeof(string));
  7.  
  8. // I will never do this
  9. PropertyCache = new Dictionary<Type, List<PropertyInfo>>();
  10.    
  11. lock(((ICollection)myObject).SyncRoot)
  12. {
  13.     //Code that should be executed by only one concurrent thread
  14.     //This is add/insert/remove/iterate/clear/etc.
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top