コード例 #1
0
        private void HandleTimerTick(object sender, EventArgs e)
        {
            if (_process == null)
            {
                return;
            }

            var      ku   = GetSnapshot();
            DateTime time = DateTime.UtcNow;

            LastDelta     = time.Subtract(_lastSnapshotTime).TotalMilliseconds;
            LastKernelPct = (ku.Item1 - _lastKt) / LastDelta;
            LastUserPct   = (ku.Item2 - _lastUt) / LastDelta;

            _lastKt           = ku.Item1;
            _lastUt           = ku.Item2;
            _lastSnapshotTime = time;

            _chart.AddValue((float)(LastKernelPct + LastUserPct) * 100);

            if (++_cycles % 10 == 0)
            {
                UpdateTitle();
            }
        }
コード例 #2
0
        private void TotalCpuSnapshot()
        {
            _cpuUsage     = _theCPUCounter.NextValue();
            _cpuIconIndex = (int)Math.Floor(_cpuUsage / 7);
            if (_cpuIconIndex > 14)
            {
                _cpuIconIndex = 14;
            }
            _trayIcon.Text = (_cpuUsage / 100).ToString("P");
            UpdateTrayIcon();

            if (_totalCpuMode)
            {
                _miniChart.AddValue(_cpuUsage);
            }
        }