Exemple #1
0
        //
        // ScavengeIdleServicePoints -
        //
        //  Removes an Idled ServicePoint as it is detected to be
        //  expired and ready to be removed.  This is called fairly
        //  often, so we should be O(1) in the case when no service points
        //  have idled.
        //

        private static void ScavengeIdleServicePoints()
        {
            DateTime now = DateTime.Now;

            GlobalLog.Enter("ServicePointManager::ScavengeIdleServicePoints() now:" + (now.ToFileTime()).ToString());
            lock (s_StrongReferenceServicePointList) {
                while (s_StrongReferenceServicePointList.Count != 0)
                {
                    DateTime expiresAt = (DateTime)s_StrongReferenceServicePointList.GetKey(0);
                    if (ServicePoint.InternalTimedOut(now, expiresAt))
                    {
                        ServicePoint servicePoint = (ServicePoint)
                                                    s_StrongReferenceServicePointList.GetByIndex(0);
                        GlobalLog.Print("ServicePointManager::ScavengeIdleServicePoints() servicePoint#" + ValidationHelper.HashString(servicePoint) + " ExpiresAt:" + (servicePoint.ExpiresAt.ToFileTime()).ToString() + " is being removed");
                        s_StrongReferenceServicePointList.RemoveAt(0);
                    }
                    else
                    {
                        // if the first in the list isn't expired, than no one later is either
                        break;
                    }
                }
            }
            GlobalLog.Leave("ServicePointManager::ScavengeIdleServicePoints");
        }