Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Diagnostics;
- public static class PerformanceManager
- {
- static PerformanceCounter cpuCounter;
- static PerformanceCounter ramCounter;
- static PerformanceManager()
- {
- cpuCounter = new PerformanceCounter();
- cpuCounter.CategoryName = "Processor";
- cpuCounter.CounterName = "% Processor Time";
- cpuCounter.InstanceName = "_Total";
- ramCounter = new PerformanceCounter("Memory", "Available MBytes");
- }
- public static string getCurrentCpuUsage()
- {
- return cpuCounter.NextValue() + "%";
- }
- public static string getAvailableRAM()
- {
- return ramCounter.NextValue() + "MB";
- }
- }
Add Comment
Please, Sign In to add comment