private void StartRegister() { try { pcount = 0; int noofaccounts = Convert.ToInt32(numericUpDown1.Value); int threads = Convert.ToInt32(numericUpDown2.Value); var options = new ParallelOptions() { CancellationToken = cts.Token, MaxDegreeOfParallelism = threads, }; Parallel.For(0, noofaccounts, options, i => { try { string proxi = null; if (checkBox3.Checked && proxies.Count > 0) { proxi = proxies[rad.Next(proxies.Count)]; } MainCode.Register(proxi, checkBox2.Checked); //pcount = pcount + 1; } catch { } finally { pcount = pcount + 1; } }); button2.Enabled = true; MessageBox.Show("Completed"); } catch (OperationCanceledException ex) { button6.Enabled = true; MessageBox.Show("CompleteD"); } }
private void process() { MainCode.Register(null, true); }