Пример #1
0
        /// <summary>
        ///     Work procedure
        /// </summary>
        private static async void UpdateStatisticWorkProc()
        {
            while (_isThreadAlive)
            {
                lock (_statisticsWorkProcSync)
                {
                    if (!_isThreadAlive)
                    {
                        return;
                    }
                    Monitor.Wait(_statisticsWorkProcSync);
                }
                if (!_isThreadAlive)
                {
                    return;
                }

                // update statistics params
                var previousGross = _estimatedGrossTweetCount;
                await UpdateTweetCount().ConfigureAwait(false);

                var delta = _estimatedGrossTweetCount - previousGross;
                System.Diagnostics.Debug.WriteLine("status count: " + _estimatedGrossTweetCount + ", delta: " + delta);

                // indicate next channel
                _currentChannel = (_currentChannel + 1) % 6;

                _tweetsCountArray[_currentChannel] = delta;

                Interlocked.Exchange(ref _tweetsPerMinutes, _tweetsCountArray.Sum());

                StatisticsParamsUpdated?.Invoke();
            }
        }
Пример #2
0
        /// <summary>
        ///     Work procedure
        /// </summary>
        private static async void UpdateStatisticWorkProc()
        {
            while (_isThreadAlive)
            {
                lock (StatisticsWorkProcSync)
                {
                    if (!_isThreadAlive)
                    {
                        return;
                    }
                    Monitor.Wait(StatisticsWorkProcSync);
                }
                if (!_isThreadAlive)
                {
                    return;
                }

                // update statistics params
                var previousGross = _estimatedGrossTweetCount;
                await UpdateTweetCount();

                var delta = _estimatedGrossTweetCount - previousGross;

                // indicate next channel
                _currentChannel = (_currentChannel + 1) % 6;

                _tweetsCountArray[_currentChannel] = delta;

                Interlocked.Exchange(ref _tweetsPerMinutes, _tweetsCountArray.Sum());

                StatisticsParamsUpdated.SafeInvoke();
            }
        }