Example #1
0
 public WorkSource()
 {
     availableWork = new ConcurrentQueue<IWork>();
     freeCrawlers = new ConcurrentQueue<ManualResetEvent>();
     workSourceScheduler = new WorkSourceScheduler();
     workSourceScheduler.OnWorkReadyForProcess(x =>
     {
         availableWork.Enqueue(x);
         NotifyFreeCrawler();
     });
     workSourceScheduler.StartManage();
 }
Example #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>();
        }