Ejemplo n.º 1
0
        protected override async Task Process()
        {
            var delay = 10;

            if ((DateTime.UtcNow - timestamp).TotalSeconds < _cfg.cpuCountIntensity)
            {
                var timeUntilNextExecution = _cfg.cpuCountIntensity - (DateTime.UtcNow - timestamp).TotalMilliseconds;
                if (timeUntilNextExecution > delay)
                {
                    delay = (int)timeUntilNextExecution;
                }
            }

            await Task.Delay(delay);

            _pm.TryUpdateCpuPerformanceCounter();
            timestamp = DateTime.UtcNow;
        }