Пример #1
0
 public WorkSource()
 {
     availableWork = new ConcurrentQueue<IWork>();
     freeCrawlers = new ConcurrentQueue<ManualResetEvent>();
     workSourceScheduler = new WorkSourceScheduler();
     workSourceScheduler.OnWorkReadyForProcess(x =>
     {
         availableWork.Enqueue(x);
         NotifyFreeCrawler();
     });
     workSourceScheduler.StartManage();
 }
Пример #2
0
        /// <summary>
        /// Releases all the work from the current <see cref="CrawlerWorkSource"/>,making it unavailable.
        /// </summary>
        public void DisposeSource()
        {
            IsSourceReleased = true;

            if (workSourceScheduler != null)
            {
                workSourceScheduler.Stop();
                workSourceScheduler = null;
            }

            ManualResetEvent handle;
            while (freeCrawlers.TryDequeue(out handle))
            {
                handle.Set();
            }

            availableWork = new ConcurrentQueue<IWork>();
        }