internal bool NeedCollection() {
if (suspendCount > 0){
return false;
}
if (handleCount > threshHold) {
threshHold = handleCount + ((handleCount * deltaPercent) / 100);
#if DEBUG_HANDLECOLLECTOR
Debug.WriteLine("HC> NeedCollection: increase threshHold to " + threshHold);
#endif
return true;
}
// If handle count < threshHold, we don't
// need to collect, but if it 10% below the next lowest threshhold we
// will bump down a rung. We need to choose a percentage here or else
// we will oscillate.
//
int oldThreshHold = (100 * threshHold) / (100 + deltaPercent);
if (oldThreshHold >= initialThreshHold && handleCount < (int)(oldThreshHold * .9F)) {
#if DEBUG_HANDLECOLLECTOR
Debug.WriteLine("HC> NeedCollection: throttle threshhold " + threshHold + " down to " + oldThreshHold);
#endif
threshHold = oldThreshHold;
}
return false;
}