コード例 #1
0
        private string CounterToString(NetworkTrafficAnalyzerCounterType counter)
        {
            switch (counter)
            {
            case NetworkTrafficAnalyzerCounterType.InLastSec:
                return("Bytes Received/sec");

            case NetworkTrafficAnalyzerCounterType.OutLastSec:
                return("Bytes Sent/sec");

            default:
                throw new ArgumentOutOfRangeException("counter");
            }
        }
コード例 #2
0
        /// <summary>
        /// Manually get a counter
        /// </summary>
        public PerformanceCounter GetCounter(string instanceName, NetworkTrafficAnalyzerCounterType counter)
        {
            var text = CounterToString(counter);

            return(new PerformanceCounter("Network Interface", text, instanceName));
        }