GSF.Diagnostics.PerformanceCounter.PerformanceCounter C# (CSharp) Method

PerformanceCounter() private method

private PerformanceCounter ( PerformanceCounter sources ) : System
sources PerformanceCounter
return System
        internal PerformanceCounter(PerformanceCounter[] sources)
        {
            if ((object)sources == null)
                throw new ArgumentNullException(nameof(sources));

            if (sources.Length < 1)
                throw new ArgumentOutOfRangeException(nameof(sources));

            PerformanceCounter initialCounter = sources[0];

            if ((object)initialCounter == null)
                throw new InvalidOperationException("No valid performance counters available");

            m_aliasName = initialCounter.m_aliasName;
            m_valueUnit = initialCounter.m_valueUnit;
            m_valueDivisor = initialCounter.m_valueDivisor;
            m_samplingWindow = initialCounter.m_samplingWindow;
            m_counter = initialCounter.m_counter;

            m_samplesLock = new object();
            m_samples = new List<float>(Enumerable.Repeat(0.0F, sources.Max(c => c.m_samples.Count)));

            for (int i = 0; i < m_samples.Count; i++)
            {
                foreach (PerformanceCounter source in sources)
                {
                    if (source.m_samples.Count > i)
                        m_samples[i] += source.m_samples[i];
                }
            }

            m_lifetimeMaximum = sources.Max(c => c.m_lifetimeMaximum);
            m_lifetimeTotal = sources.Sum(c => c.m_lifetimeTotal);
            m_lifetimeSampleCount = sources.Max(c => c.m_lifetimeSampleCount);
        }

Same methods

PerformanceCounter::PerformanceCounter ( string categoryName, string counterName, string instanceName ) : System
PerformanceCounter::PerformanceCounter ( string categoryName, string counterName, string instanceName, string aliasName ) : System
PerformanceCounter::PerformanceCounter ( string categoryName, string counterName, string instanceName, string aliasName, string valueUnit ) : System
PerformanceCounter::PerformanceCounter ( string categoryName, string counterName, string instanceName, string aliasName, string valueUnit, float valueDivisor, bool readOnly = true ) : System