private void OnLinkFinded(LinksFindedEvent eventItem)
        {
            if (_linkCounter >= _maxUrlsCount)
            {
                _queue.CompleteAdding();
                EventBus.EventBus.Instance.Unsubscribe(_eventsList.Find(x => x.EventItemType == eventItem.GetType()));
                return;
            }
            int         traverseLevel = _linkTotraversLevelDict[eventItem.ParentLink];
            WebPageLink parentLink    = new WebPageLink(eventItem.ParentLink, _linkList.First(x => x.Url == eventItem.ParentLink).TraverseLevel);

            foreach (var innerLink in eventItem.InnerLinks)
            {
                if (_linkList.FirstOrDefault(x => x.Url == innerLink) != null)
                {
                    continue;
                }
                if (_linkTotraversLevelDict.ContainsKey(innerLink))
                {
                    continue;
                }

                WebPageLink link = new WebPageLink(innerLink, parentLink.TraverseLevel + 1);
                _linkList.Add(link);
                //_queue.Add(CreateQueueItem(link));
                _queue.Add(new KeyValuePair <int, string>(traverseLevel, innerLink));

                Interlocked.Increment(ref _linkCounter);

                if (_linkCounter >= _maxUrlsCount)
                {
                    _queue.CompleteAdding();
                    EventBus.EventBus.Instance.Unsubscribe(_eventsList.Find(x => x.EventItemType == eventItem.GetType()));
                    break;
                }
            }
        }
        private void OnLinkFinded(LinksFindedEvent eventItem)
        {
            if (_linkQueue.IsAddingCompleted)
            {
                return;
            }

            lock (_lock)
            {
                if (_linkCounter >= _maxUrlsCount)
                {
                    _linkQueue.CompleteAdding();
                    EventBus.EventBus.Instance.Unsubscribe(_subscriptions.Find(x =>
                                                                               x.EventItemType == eventItem.GetType()));
                    return;
                }
                var delta  = _maxUrlsCount - _linkCounter;
                var prLink = _linkList.Find(x => x.Url == eventItem.ParentLink);
                if (prLink == null)
                {
                    return;
                }
                var         parentTraverseLevel = prLink.TraverseLevel;
                WebPageLink parentLink          = new WebPageLink(eventItem.ParentLink, parentTraverseLevel);
                foreach (var innerLink in eventItem.InnerLinks.Take(delta))
                {
                    if (!_linkList.Any(x => x.Url == innerLink))
                    {
                        AddLink(innerLink, parentLink.TraverseLevel + 1);
                    }
                }
            }
        }