public void Start() { while (true) { try{ TokenCrawler.ThrowIfCancellationRequested(); _jobCompanyCrawler = GetCompanyCrawler(); if (_jobCompanyCrawler != null && _jobCompanyCrawler.CompanyID > 0) { var companyId = _jobCompanyCrawler.CompanyID; if (companyId <= 0) { continue; } TokenCrawler.ThrowIfCancellationRequested(); _countCompany++; CrawlForCompany(companyId); } else { const int sleepGetCompany = 10; LogData(string.Format("TH {0} not company crawler. Sleep {1}s", _indexThread, sleepGetCompany)); TokenCrawler.WaitHandle.WaitOne(sleepGetCompany * 1000); } } catch (OperationCanceledException) { throw; } catch (Exception ex) { _log.Error(ex); Thread.Sleep(10000); } } }
public void Start() { while (true) { try { _tokenCrawler.ThrowIfCancellationRequested(); this.jobCrawler = GetCompanyCrawler(); if (this.jobCrawler != null && this.jobCrawler.CompanyID > 0) { var companyId = this.jobCrawler.CompanyID; if (companyId > 0) { _tokenCrawler.ThrowIfCancellationRequested(); _countCompany++; CrawlForCompany(jobCrawler.CompanyID); } } else { int sleepGetCompany = 10; LogData(string.Format("TH {0} not company crawler. Sleep {1}s", _indexThread, sleepGetCompany)); _tokenCrawler.WaitHandle.WaitOne(sleepGetCompany * 1000); } } catch (OperationCanceledException) { return; } catch (Exception ex) { _log.Error(ex); Thread.Sleep(10000); } } }