Exemplo n.º 1
0
        /// <summary>
        /// Obtain new sample from performance counters, and refresh the values saved in dlSpeed, ulSpeed, etc.
        /// This method is supposed to be called only in NetworkMonitor, one time every second.
        /// </summary>
        internal void Refresh()
        {
            _dlValue = DlCounter.NextSample().RawValue;
            _ulValue = UlCounter.NextSample().RawValue;

            // Calculates download and upload speed.
            _dlSpeed = _dlValue - _dlValueOld;
            _ulSpeed = _ulValue - _ulValueOld;

            _dlValueOld = _dlValue;
            _ulValueOld = _ulValue;
        }
Exemplo n.º 2
0
        internal PerformanceCounter DlCounter, UlCounter;       // Performance counters to monitor download and upload speed.

        /// <summary>
        /// Preparations for monitoring.
        /// </summary>
        internal void Init()
        {
            // Since dlValueOld and ulValueOld are used in method refresh() to calculate network speed, they must have be initialized.
            _dlValueOld = DlCounter.NextSample().RawValue;
            _ulValueOld = UlCounter.NextSample().RawValue;
        }