把一个小时内cpu的使用率按照时间间隔对应的存储在内存中,如:8:00  30%      9:00   40%       10:00    50%  这样

解决方案 »

  1.   


    using System;
    using System.Diagnostics;namespace ConsoleApplication1
    {
        class Program
        {
            private static PerformanceCounter ProcessorUsage = new PerformanceCounter("Processor", "% Processor Time", "_Total");//定義CPU效能計數器        static void Main(string[] args)
            {
                while (true)
                {
                    string CpuRate = decimal.Round(decimal.Parse(ProcessorUsage.NextValue().ToString()), 0, MidpointRounding.ToEven) + "%";//取得CPU使用率 
                    Console.WriteLine(CpuRate);
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
    }
      

  2.   


    用List<T>这样的格式存储?