Пример #1
0
 public static void Test()
 {
     MultiThreadingWorker thWork = new MultiThreadingWorker();
     thWork.threadCount = 20;
     thWork.workContent = new WorkContent(WorkFun);
     for (int i = 0; i < 100; i++)
         thWork.AddWork(i);
     thWork.Start();
 }
Пример #2
0
        /// <summary>
        /// 开始
        /// </summary>
        /// <param name="baseurl"></param>
        public void StartSpider(string baseurl)
        {
            m_already = new Hashtable();
            m_base = new Uri(baseurl);
            m_startTime = System.DateTime.Now.Ticks;

            thWork = new MultiThreadingWorker();
            thWork.threadCount = 20;
            thWork.workContent = new WorkContent(GetPage);
            if (!m_already.Contains(m_base))
            {
                m_already.Add(m_base, Status.STATUS_QUEUED);
                thWork.AddWork(m_base);
            }
            
            thWork.Start();
        }
Пример #3
0
        private static void ParseContent(Uri uri, Book book, BookRule rule,int pagenum)
        {
            if (rule.content_rule != "" && book.catalogs!=null)
            {
                MultiThreadingWorker thWork = new MultiThreadingWorker();
                thWork.threadCount = 20;
                thWork.workContent = new WorkContent(ParsePage);
                for (int i = 0; i < book.catalogs.Count; i++)
                {
                    if (pagenum > 0 && pagenum < i + 1) break;//预览

                    thWork.AddWork(book.catalogs[i]);
                }
                thWork.Start();
            }
        }