code_junkie

Collections optimized for concurrency in .Net

Nov 13th, 2011
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. Queue myCollection = new Queue();
  2.  
  3. lock(myCollection.SyncRoot)
  4. {
  5. foreach (Object item in myCollection)
  6. {
  7. // Insert your code here.
  8. }
  9. }
  10.  
  11. Queue mySyncCollection = Queue.Synchronized(myCollection);
  12. // No locks required
Add Comment
Please, Sign In to add comment