Esempio n. 1
0
        private async void TryExecuteNext()
        {
            lock (_lock)
            {
                if (_currentCommand != null || !CommandQueue.Any())
                {
                    return;
                }

                _currentCommand = CommandQueue.Dequeue();
            }

            await _currentCommand.ExecuteAsync();

            lock (_lock)
            {
                _currentCommand = null;
            }

            TryExecuteNext();
        }
        private async void TryExecuteNext()
        {
            lock (this._lock)
            {
                if (this._currentCommand != null || !this.CommandQueue.Any())
                {
                    return;
                }

                this._currentCommand = this.CommandQueue.Dequeue();
            }

            await this._currentCommand.ExecuteAsync();

            lock (this._lock)
            {
                this._currentCommand = null;
            }

            this.TryExecuteNext();
        }