I recently wanted to get the usage of my CPU in C#. After searching the internet I found a way of doing it using the PerfomanceCounter class. I made a couple of changes and I created the following class, which seems to work.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;</code>

{
   public class SystemUtils
   {
      public static long getCpuUsage()
      {
        PerformanceCounter cpuCounter;
        cpuCounter = new PerformanceCounter();

        cpuCounter.CategoryName = "Processor";
        cpuCounter.CounterName = "% Processor Time";
        cpuCounter.InstanceName = "_Total";

        cpuCounter.NextValue();
        System.Threading.Thread.Sleep(1000);
        return (int) cpuCounter.NextValue();
      }
    }
}

Using the statement: SystemUtils.getCpuUsage() you should be able to get an integer number showing the CPU usage.

A few weeks ago (http://kyriakos.anastasakis.net/prof/blog/?p=24) I posted that I was interested in .NET certification. Unfortunately I haven’t had the time to work on it since then. The main incentive was to get acquainted with the DSL tools provided in .NET 3.0 (even though the available certification exams are only for .NET 2.0).

Today I read an article in ComputerWeekly that there is a shortage of .NET skills (http://www.computerweekly.com/Articles/2007/09/03/226513/employers-struck-by-shortage-of-.net-skills.htm)

It would be interesting to work on a contact .NET project and see the potential of applying Model Driven techniques in practice… But I guess I will have to find some time to study for the certification first.