code_junkie

Concurrent collections in C#

Nov 10th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. foreach (String s in (List<String> )callingForm.Invoke(callingForm.delegateGetKillStrings))
  2. {
  3. //do some jazz
  4. }
  5.  
  6. private void addKillString(String s)
  7. {
  8. lock (killStrings)
  9. {
  10. killStrings.Add(s);
  11. }
  12. }
  13.  
  14. List<string> theList = (List<String> )callingForm.Invoke(callingForm.delegateGetKillStrings);
  15. lock(theList.SyncRoot) {
  16. foreach(string s in theList) {
  17. // Do some Jazz
  18. }
  19. }
Add Comment
Please, Sign In to add comment