Пример #1
0
        private void TileFetchLoop(object state)
        {
            try
            {
                var retries = new Retries(_maxAttempts);

                while (_isThreadRunning)
                {
                    if (_tileSource.Schema == null)
                    {
                        _waitHandle.Reset();
                    }

                    _waitHandle.WaitOne();
                    Busy = true;

                    if (_isViewChanged && (_tileSource.Schema != null))
                    {
                        var levelId = BruTile.Utilities.GetNearestLevel(_levelManager.TileResolutions, _resolution);
                        _missingTiles      = _strategy.GetTilesWanted(_tileSource.Schema, _extent.ToExtent(), levelId);
                        _numberTilesNeeded = _missingTiles.Count;
                        retries.Clear();
                        _isViewChanged = false;
                    }

                    _missingTiles = GetTilesMissing(_missingTiles, _memoryCache, retries);

                    FetchTiles(retries);

                    if (_missingTiles.Count == 0)
                    {
                        Busy = false;
                        _waitHandle.Reset();
                    }

                    if (_threadCount >= _maxThreads)
                    {
                        _waitHandle.Reset();
                    }
                }
            }
            finally
            {
                _isThreadRunning = false;
            }
        }
Пример #2
0
        private void TileFetchLoop(object state)
        {
            try
            {
                while (isThreadRunning)
                {
                    if (tileSource.Schema == null)
                    {
                        waitHandle.Reset();
                    }

                    waitHandle.WaitOne();

                    if (isViewChanged && (tileSource.Schema != null))
                    {
                        int level = BruTile.Utilities.GetNearestLevel(tileSource.Schema.Resolutions, resolution);
                        missingTiles = strategy.GetTilesWanted(tileSource.Schema, extent.ToExtent(), level);
                        retries.Clear();
                        isViewChanged = false;
                    }

                    missingTiles = GetTilesMissing(missingTiles, memoryCache, retries, maxRetries);

                    FetchTiles();

                    if (missingTiles.Count == 0)
                    {
                        waitHandle.Reset();
                    }

                    if (threadCount >= ThreadMax)
                    {
                        waitHandle.Reset();
                    }
                }
            }
            finally
            {
                isThreadRunning = false;
            }
        }