Login | Register
My pages Projects Community openCollabNet

Discussions > commits > [chorns] 530: Avoid modifying lockset collection while enumerating

sin
Discussion topic

Back to topic list

[chorns] 530: Avoid modifying lockset collection while enumerating

Reply

Author chorns
Full name Casper Hornstrup
Date 2005-09-09 08:19:26 PDT
Message Avoid modifying lockset collection while enumerating
Modified: trunk/Sin.Integratio​nManager.Service/Loc​kManager.cs
  _____

Modified: trunk/Sin.Integratio​nManager.Service/Loc​kManager.cs
--- trunk/Sin.Integratio​nManager.Service/Loc​kManager.cs 2005-09-09
15:11:51 UTC (rev 529)
+++ trunk/Sin.Integratio​nManager.Service/Loc​kManager.cs 2005-09-09
15:18:31 UTC (rev 530)
@@ -432,12 +432,18 @@

             DateTime border = DateTime.Now.AddDays(-1);
             lock (this)
             {
+ Stack locksetsToBeRemoved = new Stack();
                 foreach (DictionaryEntry de in locksets)
                 {
                     Lockset lockset = de.Value as
Lockset;
                     if (lockset.Created < border)
- RemoveLockSet(lockset);
+
locksetsToBeRemoved.​Push(lockset);
                 }
+ while (locksetsToBeRemoved.Count > 0)
+ {
+ Lockset lockset =
locksetsToBeRemoved.Pop() as Lockset;
+ RemoveLockSet(lockset);
+ }
             }
         }
Attachments

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

[chorns] 530: Avoid modifying lockset collection while enumerating chorns Casper Hornstrup 2005-09-09 08:19:26 PDT
Messages per page: