예제 #1
0
        private void UpdateCore()
        {
            PersistentQueueMessage message = _queueReader.Dequeue();

            while (message != null)
            {
                Process(message);
                _queueReader.Delete(message);

                message = _queueReader.Dequeue();
            }
        }
        private IConcurrentDocument <DashboardVersion> StartRestoringArchive(IConcurrentDocument <DashboardVersion> version)
        {
            const int IndexerPollIntervalMilliseconds = 5000;

            _dashboardVersionManager.StartRestoringArchive(version.ETag);

            PersistentQueueMessage message = _upgradeQueueReader.Dequeue();

            int count = 0;

            do
            {
                while (message != null)
                {
                    version = _dashboardVersionManager.Read();
                    if (version.Document.UpgradeState != DashboardUpgradeState.RestoringArchive)
                    {
                        _upgradeQueueReader.TryMakeItemVisible(message);
                        return(version);
                    }

                    // Delete auto-"archives" from host-archive back to host-output.
                    _upgradeQueueReader.Delete(message);

                    message = _upgradeQueueReader.Dequeue();
                }

                version = _dashboardVersionManager.Read();
                if (version.Document.UpgradeState != DashboardUpgradeState.RestoringArchive)
                {
                    return(version);
                }

                // Get items left
                // while limiting pagination to first page since we're only interested in
                // knowing if we're out of items.
                count = _upgradeQueueReader.Count(1);
                if (count > 0)
                {
                    // wait for a while before resuming
                    Thread.Sleep(IndexerPollIntervalMilliseconds);
                }
            }while (count > 0);

            return(version);
        }