void DoWork() { int.TryParse(TxtTo.Text, out int VoteNumber); int.TryParse(TxtFrom.Text, out int From); FlatProgressBar.Maximum = VoteNumber == 0 ? AccountsData.Count - From : VoteNumber - From; FlatProgressBar.Value = 0; long Number = VoteNumber - From; var Interval = IntInterval.Value; string uri = TxtPostID.Text; int selected_choice = (int)IntVoteOption.Value; Options.From = From; Options.To = VoteNumber; Options.Interval = (int)Interval; Options.Option = selected_choice; Options.PostId = uri; SaveOptions(); Job = new Thread(() => { for (int i = From; i < AccountsData.Count; i++) { var data = AccountsData[i]; this.Invoke((MethodInvoker) delegate { Options.From++; SaveOptions(); }); try { if (Number > 0 && Success >= Number) { break; } var twitter = new TwitterClient(data.UserName, data.Password, data.Verify); twitter.CheckCookies(); bool success = false; if (twitter.CookiesFound) { this.Invoke((MethodInvoker) delegate { this.RTStatus.AppendText($"\n[{DateTime.Now}] Cookies Found " + data.UserName); success = true; }); } else { this.Invoke((MethodInvoker) delegate { this.RTStatus.AppendText($"[{DateTime.Now}] Start Login Process"); }); success = twitter.Login(); if (success) { this.Invoke((MethodInvoker) delegate { this.RTStatus.AppendText($"\n[{DateTime.Now}] Success Login To " + data.UserName); }); } } if (success) { twitter.Vote(uri, selected_choice); Success++; this.Invoke((MethodInvoker) delegate { this.RTStatus.AppendText($"\n[{DateTime.Now}] Success Vote"); }); } else { this.Invoke((MethodInvoker) delegate { this.RTStatus.AppendText($"[{DateTime.Now}] Failed Vote"); }); Failed++; } } catch (Exception) { Failed++; } this.Invoke((MethodInvoker) delegate { this.FlatProgressBar.Increment(1); }); SetText($"Twitter Auto Voter ({this.FlatProgressBar.Value} / {(Number == 0 ? AccountsData.Count - From : Number - From)}) || Success= {Success} || Failed= {Failed}"); if (Interval > 0) { Thread.Sleep((int)Interval * 1000); } } this.Invoke((MethodInvoker) delegate { EnabledComp(); this.ProgressOngoing = false; Success = Failed = 0; }); Job = null; }); Job.Start(); }