Пример #1
0
        private void TimerElapsed(object state)
        {
            try
            {
                if (!IsBusy && (_requestQueue.Count > 0 || _lowPriorityRequestQueue.Count > 0))
                {
                    lock (_syncLock)
                    {
                        if (!IsBusy && (_requestQueue.Count > 0 || _lowPriorityRequestQueue.Count > 0))
                        {
                            IsBusy = true;

                            if (_requestQueue.Count > 0)
                            {
                                _currentRequest = _requestQueue.Dequeue();
                            }
                            else
                            {
                                _currentRequest = _lowPriorityRequestQueue.Dequeue();
                            }

                            Debug.WriteLine("Request executing");
                            _currentRequest.Execute();
                        }
                    }
                }
            }
            finally
            {
                _requestTimer.Change(1, Timeout.Infinite);
            }
        }
Пример #2
0
        public void Teardown()
        {
            _isTearingDown = true;

            _requestTimer.Change(Timeout.Infinite, Timeout.Infinite);
            _requestTimer.Dispose();

            _requestQueue.Clear();
            _lowPriorityRequestQueue.Clear();
            _currentRequest = null;

            TeardownLibraryHandlers();
            TeardownPlaybackHandlers();
        }