private void AddMarketThread() { try { AddMarket avail_market = ActiveMdiChild as AddMarket; string bookies = SelectedBookies(); foreach (string market in addmarkets) { string[] info1 = market.Split(','); if (info1.Length > 1) { Task.Factory.StartNew(() => { avail_market.FillData(info1[2], Convert.ToInt64(info1[0]), Convert.ToInt64(info1[1]), bookies, addmarkets.Count); }, TaskCreationOptions.LongRunning); } } } catch (Exception ex) { } }
private void toolStripMenuItem2_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(SelectedBookies())) { if (ActiveMdiChild is OddsCrawler) { if (IsProcessRunning) { MessageBox.Show("A process is already running"); return; } OddsCrawler crawl = ActiveMdiChild as OddsCrawler; markets = crawl.SelectedMarkets(); if (markets.Count > 0) { crawl.ClearFlowLayoutPanel(); SetProgress(true); IsProcessRunning = true; crawl.countthread = 0; string[] sportid = markets[0].Split(','); if (sportid.Length > 1) { crawl.SetLabelSportIdText(sportid[3]); } //string bookies = SelectedBookies(); //foreach (string market in markets) //{ //string[] info = market.Split(','); //Task taskB = Task.Factory.StartNew(() => //{ // crawl.FillData(info[2], Convert.ToInt64(info[0]), Convert.ToInt64(info[1]), bookies, markets.Count); Thread thread = new Thread(MyThread); thread.Start(); //}); } //} } else if (ActiveMdiChild is AddMarket) { if (IsProcessRunning) { MessageBox.Show("A process is already running"); return; } AddMarket crawl1 = ActiveMdiChild as AddMarket; addmarkets = crawl1.SelectedMarkets(); if (addmarkets.Count > 0) { //List<string> markets = crawl.SelectedMarkets(); crawl1.ClearFlowLayoutPanel(); SetProgress(true); IsCouponProcessRunning = true; crawl1.countthread = 0; Thread thread = new Thread(AddMarketThread); thread.Start(); } } else if (ActiveMdiChild is Coupons) { if (IsCouponProcessRunning) { MessageBox.Show("A process is already running"); return; } Coupons coupon = ActiveMdiChild as Coupons; if (coupon.SelectedMarkets().Count > 0) { List <string> markets = coupon.SelectedMarkets(); coupon.ClearFlowLayoutPanel(); SetProgress(true); IsCouponProcessRunning = true; coupon.countthread = 0; Task taskB = Task.Factory.StartNew(() => { foreach (string market in markets) { string[] info = market.Split(','); coupon.FillData(info[2], Convert.ToInt64(info[0]), Convert.ToInt64(info[1]), info[3], markets.Count); } }); } else { MessageBox.Show("Please select a coupon"); } } else if (ActiveMdiChild is UpdatePrice) { if (IsCouponProcessRunning) { MessageBox.Show("A process is already running"); return; } UpdatePrice update = ActiveMdiChild as UpdatePrice; updatemarkets = update.SelectedMarkets(); if (updatemarkets.Count > 0) { //List<string> markets = crawl.SelectedMarkets(); update.ClearFlowLayoutPanel(); SetProgress(true); IsCouponProcessRunning = true; update.countthread = 0; Thread thread = new Thread(UpdateMarketThread); thread.Start(); //foreach (string market in markets) //{ // string[] info = market.Split(','); // Task taskB = Task.Factory.StartNew(() => // { // crawl.FillData(info[2], Convert.ToInt64(info[0]), Convert.ToInt64(info[1]), SelectedBookies(), markets.Count); // }); //} } } else { MessageBox.Show("Please select atleast one market"); } } else { MessageBox.Show("Please select atleast one bookie from Select Bookies menu"); } } catch (Exception ex) { IsProcessRunning = false; SetProgress(false); IsCouponProcessRunning = false; } }
private void btnaddmarket_Click(object sender, EventArgs e) { if (flowLayoutPanel1.Controls.Count > 0) { long matchid = Convert.ToInt64(txtmatchdate.Name); string couponid = lblmatchnotset.Name; GenerateCoupon coupon = new GenerateCoupon(); DataSet ds = coupon.GetAvailableMarkets(matchid, couponid); if (ds.Tables[0].Rows.Count > 0) { Form childForm = new AddMarket(matchid, couponid); childForm.MdiParent = this.MdiParent; //childForm.Text = "Window " + childFormNumber++; childForm.Show(); } else { MessageBox.Show("All markets are priced"); } } else { MessageBox.Show("Data not available!"); } }