Exemplo n.º 1
0
        public CounterProvider(CounterFinder finder)
        {
            //
            // Cache strategy
            // key: performance counter category, value: Counter Monitor
            // key: performance counter category + performance counter instance, value: list of performance counters
            // Cache stores one counter monitor per performance counter category
            // When performance counters are requested they are added to the monitor for their category and then cached under category + instance
            //     for quick retrieval and lifetime management
            _cache = new MemoryCache(new MemoryCacheOptions()
            {
                ExpirationScanFrequency = CacheExpiration,
                CompactOnMemoryPressure = false
            });

            _counterFinder = finder;

            _concurrentCacheHelper = new ConcurrentCacheHelper(_cache);

            _cacheEvicter = new Timer(TimerCallback, null, ScanFrequency, ScanFrequency);
        }
Exemplo n.º 2
0
 public CounterMonitor(CounterFinder finder, IEnumerable <IPerfCounter> counters)
 {
     _counterFinder = finder;
     AddCounters(counters);
 }