Пример #1
0
        private void RespCallback(IAsyncResult iar)
        {
            Requests request = (Requests)iar.AsyncState;

            string page;
            bool   success = request.EndGetResponse(iar, out page);

            lock (m_locker)
            {
                if (success)
                {
                    m_parser.TryParse(page, request.Id);
                }
                else if (m_storeUnprocessedIds)
                {
                    m_badIds.Enqueue(request.Id);
                }
            }
            request.Dispose();
            m_semaphore.Release();

            if (success && PageDownloadingComplete != null)
            {
                PageDownloadingComplete(null, EventArgs.Empty);
            }
        }
Пример #2
0
        private void RespCallback(IAsyncResult iar)
        {
            Requests request = (Requests)iar.AsyncState;

            string page;
            bool   endGetResponse = request.EndGetResponse(iar, out page);

            lock (_locker)
            {
                if (endGetResponse)
                {
                    _parser.TryParse(page, request.Id);
                }
                else
                {
                    _badIds.Enqueue(request.Id);
                }
            }
            request.Dispose();
            _semaphore.Release();

            if (endGetResponse && PageDownloadingComplete != null)
            {
                PageDownloadingComplete(null, EventArgs.Empty);
            }
        }