티스토리 뷰

언어/C#

[C#] CPU 이용률 알아보기.

최우림 -=HaeJuK=- 2010.04.23 17:50

 using System.Diagnostics ;

 protected PerformanceCounter cpuCounter;

 public MyMain(LoginData _Data)
        {
            cpuCounter = new PerformanceCounter();
            cpuCounter.CategoryName = "Processor";                 
            cpuCounter.CounterName = "% Processor Time";
            cpuCounter.InstanceName = "_Total";

         }


 private void MyMain_Load(object sender, EventArgs e)
        {
            Timer T = new Timer();
            T.Interval = 1000;
            T.Tick += new EventHandler(UseingCpuPer);
            T.Start();
        }


  public void UseingCpuPer(Object sender , EventArgs e)
        {
            progressBar3.Value= (int)cpuCounter.NextValue();
            label54.Text = progressBar3.Value.ToString();
          }

댓글