Beispiel #1
0
        public void Start()
        {
            ProductAdapter productAdapter       = new ProductAdapter(new SqlDb(Server.ConnectionString));
            List <long>    lstCOmpanyDownloaded = productAdapter.GetCOmpanyDownloadedHTML();

            foreach (long companyID in productAdapter.GetAllCompanyIdCrawler())
            {
                if (!lstCOmpanyDownloaded.Contains(companyID))
                {
                    lst.Enqueue(companyID);
                }
            }
            int MaxThread = 100;

            for (int i = 0; i < MaxThread; i++)
            {
                int jThread = i;
                Task.Factory.StartNew(() =>
                {
                    WorkerExportHtml worker   = new WorkerExportHtml(jThread);
                    worker.eventGetCompanyID += new WorkerExportHtml.GetCompanyId(GetCompanyCrawler);
                    worker.eventProcessHtml  += new WorkerExportHtml.DelegateProcessHtml(SaveHtml);
                    worker.eventWhenFinish   += new WorkerExportHtml.DelegateWhenFinish(EventWhenFinsih);
                    worker.Start();
                });
            }
        }