From: Pavol S. <st...@st...> - 2003-02-23 00:21:35
|
Great thats it... first... sorry again for my mailing list misstake... i had bad addres in addressbook... BTW: Named parameters are working great for me... Next questions: why you are doing this? (marked by arrow) FbConnectionPool.cs private void CleanUp(object State) { long now = System.DateTime.Now.Ticks; Object o; lock (unlocked.SyncRoot) { IDictionaryEnumerator e = unlocked.GetEnumerator(); while (e.MoveNext()) { o = e.Key; if (((ConnectionData)e.Value).lifetime != 0) { if ((now - ((ConnectionData)e.Value).created) > ((ConnectionData)e.Value).lifetime) { unlocked.Remove(o); Expire(o); o = null; // Rebuild Enumeration -> e = unlocked.GetEnumerator(); } } } } } i think you can remove it becouse unlocked is locked and in while you move to next, so you will not read null connection... To clean up unlocked you can put that line after while loop... Reason for this is: If you have 100 pooled connections first 50 is ok and last 50 is old, so you will go throw first 50 and then you will remove 51 and GetEnumerator() will reset counter to 0 so you will do it again from zero... so you will do 50x50 (litle more) while cycles... In my case you will do only 100 cycles... If im wrong write it... Im just learning your code... next think is: private void RunCleanUp() { TimeSpan interval = new TimeSpan(0, 0, 10); while (true) { -> lock (this) { CleanUp(null); } Thread.Sleep(interval); } } you dont need to lock whole class instance, becouse in CleanUp you are working only with unlocked instance variable and its locked there... If you have lot of connections (and there is above situation) pool is locked too long... My be you can use ReaderWriterLock so there will be nothing locked too long, but it wants more work... again teach me more if im wrong... thanx p. |