System.Runtime.InteropServices.HandleCollector.Remove C# (CSharp) Method

Remove() public method

public Remove ( ) : void
return void
        public void Remove () {
            Interlocked.Decrement( ref handleCount);
            if (handleCount < 0) {
                throw new InvalidOperationException(SR.GetString(SR.InvalidOperation_HCCountOverflow)); 
            }

            int newThreshold =  handleCount + handleCount/deltaPercent;
            if (newThreshold < (threshold - threshold/deltaPercent)) {
                lock( this) {
                   if (newThreshold > initialThreshold) {
                        threshold = newThreshold;
                    }
                    else {
                        threshold = initialThreshold;
                    }
                    gc_gen = 0;
                }
            }
            
            for (int i = 1; i < 3; i++) {
                gc_counts [i] = GC.CollectionCount (i);
            }            
        }
    }

Usage Example

コード例 #1
0
 public static void EmptyRemoval()
 {
     HandleCollector collector = new HandleCollector("EmptyRemoval", 10);
     Assert.Throws<InvalidOperationException>(() => collector.Remove());
 }
All Usage Examples Of System.Runtime.InteropServices.HandleCollector::Remove