public static void RunRequestByStatus(DataGridView data) { for (int i = 0; i < data.Rows.Count; i++) { if (Convert.ToInt32(data.Rows[i].Cells["ui_status"].Value) == 2) { BuySellBot.ItemRequest(csgo_itemRequest + keyMarket); } } }
public static void RunRequestByStatus(DataGridView data, IProgress <string> progress, ref bool requestMode) { for (int i = 0; i < data.Rows.Count; i++) { if (Convert.ToInt32(data.Rows[i].Cells["ui_status"].Value) == 2) { BuySellBot.ItemRequest(csgo_itemRequest + keyMarket); } progress.Report(Convert.ToDouble((i + 1) * 100 / data.Rows.Count).ToString() + "%"); } requestMode = false; }
//void RunItemRequest(IProgress<string> progress) //{ // for (int i = 0; i < dataGridView1.Rows.Count; i++) // { // if(Convert.ToInt32(dataGridView1.Rows[i].Cells["ui_status"].Value)==2) // BuySellBot.ItemRequest(@"https://market.csgo.com/api/ItemRequest/in/1/?key=" + Info.key);//" + dataGridViewTrades.Rows[i].Cells["bot_id"].Value.ToString() + " // Thread.Sleep(2); // progress.Report(Convert.ToDouble((i+1) * 100 / dataGridView1.Rows.Count).ToString() + "%"); // } // requestMode = false; //} private async void buttonItemRequestMode_Click_1(object sender, EventArgs e) { var progress = new Progress <string>(s => labelProgress.Text = s); buttonItemRequestMode.Visible = false; buttonItemRequestModeOff.Visible = true; await Task.Factory.StartNew(() => { forKill = Thread.CurrentThread; BuySellBot.RunRequestByStatus(dataGridView1, progress, ref requestMode); buttonItemRequestModeOff.BeginInvoke((MethodInvoker)(() => { buttonItemRequestModeOff.Visible = false; buttonItemRequestMode.Visible = true; })); }); requestMode = false; }
private void timerRequest_Tick(object sender, EventArgs e) { BuySellBot.RunRequestByStatus(dataGridView1); }