public override Dictionary <GCSampleType, float> Sample()
        {
            var inducedCount = _inducedCount.Exchange(0);

            var result = new Dictionary <GCSampleType, float>()
            {
                { GCSampleType.Gen0Size, (ulong)_gen0Size },
                { GCSampleType.Gen0Promoted, (ulong)_gen0Promoted },
                { GCSampleType.Gen1Size, (ulong)_gen1Size },
                { GCSampleType.Gen1Promoted, (ulong)_gen1Promoted },
                { GCSampleType.Gen2Size, (ulong)_gen2Size },
                { GCSampleType.Gen2Survived, (ulong)_gen2Promoted },
                { GCSampleType.LOHSize, (ulong)_lohSize },
                { GCSampleType.LOHSurvived, (ulong)_lohPromoted },
                { GCSampleType.HandlesCount, (uint)_handlesCount },
                { GCSampleType.InducedCount, inducedCount }
            };

            if (_collectionCountPerGen.Length > 0)
            {
                result[GCSampleType.Gen0CollectionCount] = _collectionCountPerGen[0].Exchange(0);
            }
            if (_collectionCountPerGen.Length > 1)
            {
                result[GCSampleType.Gen1CollectionCount] = _collectionCountPerGen[1].Exchange(0);
            }
            if (_collectionCountPerGen.Length > 2)
            {
                result[GCSampleType.Gen2CollectionCount] = _collectionCountPerGen[2].Exchange(0);
            }

            return(result);
        }
        private bool TryGetCount(InterlockedCounter counter, out int metricCount)
        {
            metricCount = 0;
            if (counter.Value > 0)
            {
                metricCount = counter.Exchange(0);
                return(true);
            }

            return(false);
        }