Esempio n. 1
0
        public static void Collect(int generation, GCCollectionMode mode, bool blocking, bool compacting)
        {
            if (generation < 0)
            {
                throw new ArgumentOutOfRangeException("generation", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
            }
            if (mode < GCCollectionMode.Default || mode > GCCollectionMode.Optimized)
            {
                throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_Enum"));
            }
            int mode1 = 0;

            if (mode == GCCollectionMode.Optimized)
            {
                mode1 |= 4;
            }
            if (compacting)
            {
                mode1 |= 8;
            }
            if (blocking)
            {
                mode1 |= 2;
            }
            else if (!compacting)
            {
                mode1 |= 1;
            }
            GC._Collect(generation, mode1);
        }
Esempio n. 2
0
 public static void Collect()
 {
     GC._Collect(-1, 2);
 }