IDLE Time Logical Disk

Alexander Hecht 0 Reputation points


does anyone know, how to read the idle time of logical disks in C#?

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,500 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 82,491 Reputation points

    You can use Performance Counters

    Something like this :

                   System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
                    EventWaitHandle evt = new ManualResetEvent(false);
                    new Thread(() => MonitorCounter("LogicalDisk", "% Idle Time", "C:", evt)).Start();
            void MonitorCounter(string sCategory, string sCounter, string sInstance, EventWaitHandle evt)
                using (PerformanceCounter pc = new PerformanceCounter(sCategory, sCounter, sInstance))
                    while (!evt.WaitOne(500, false))
                        float nValue = pc.NextValue();
                        Console.WriteLine(sCounter + " : {0}", Convert.ToString(Math.Round(nValue, 3)));                    
    0 comments No comments