public string CrawlBettingLinks() { TraceService("Crawl BettingLinks Started: "); try { CrawlFirstPageData crawldata = new CrawlFirstPageData(); DataTable dt = crawldata.GetMatchInfo(); //Task[] tasks = new Task[dt.Rows.Count]; // for (int i = 0; i < dt.Rows.Count; i++) // { // string url = dt.Rows[i]["BettingLink"].ToString(); // int id = Convert.ToInt32(dt.Rows[i]["id"].ToString()); // tasks[i] = Task.Factory.StartNew(() => // { // CrawlBettingMarkets(url, id); // },TaskCreationOptions.LongRunning); // } // Task.WaitAll(tasks); for (int i = 0; i < dt.Rows.Count; i++) { string url = dt.Rows[i]["BettingLink"].ToString(); int id = Convert.ToInt32(dt.Rows[i]["id"].ToString()); ThreadParameters tp = new ThreadParameters(); tp.URL = url; tp.MatchID = id; ThreadPool.QueueUserWorkItem(new WaitCallback(CrawlBettingMarkets), tp); } return "Command completed successfully"; } catch (Exception ex) { ErrorLog("CrawlBettingMarket ---- Error:"+ex.ToString()); return ex.Message; } }
public DataTable GetMatchInfo(long matchid) { CrawlFirstPageData crawl = new CrawlFirstPageData(); DataTable dt = crawl.GetMatchInfo(matchid); return dt; }