private void AccountLogger_OnAcceptListener(CookieContainer session, string phoneNumber) { Logger.LogMessage(this, phoneNumber + " successfully approved."); tempSessions.Add(phoneNumber + ":" + CookiesHelper.GetCookies(session)); var item = lstAccounts.FindItemWithText(phoneNumber); item.SubItems[1].Text = "Accepted"; item.BackColor = Color.Green; var commentSender = new CommentSender(this, session, inputs.Posts, inputs.Comments, phoneNumber); commentSender.Execute(); }
private void btnStart_Click(object sender, EventArgs e) { try { if (lstAccounts.Items.Count == 0) { MessageBox.Show(Globals.ErrorMessage_PhoneNumbersNull, Globals.ErrorMessage_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (inputs.Posts.Count == 0) { MessageBox.Show(Globals.ErrorMessage_PostsNull, Globals.ErrorMessage_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (inputs.Comments.Count == 0) { MessageBox.Show(Globals.ErrorMessage_CommentsNull, Globals.ErrorMessage_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Logger.LogMessage(this, "Started sending."); Statistics.WorkStatus = true; Statistics.Trys = 0; Statistics.TotalSends = 0; Statistics.Errors = 0; Statistics.ActiveThreads = 1; Statistics.ElapsedTime = "00:00:00"; tmrWatch.Start(); watch.Restart(); grpInputs.Enabled = false; btnStart.Enabled = false; btnRemoveDup.Enabled = false; //inputs.CommentPerPost = txtCommentPerPost.Text; //inputs.MinThreads = txtMinThreads.Text; //inputs.MaxThreads = txtMaxThreads.Text; //int minThreads = int.Parse(inputs.MinThreads); //int maxThreads = int.Parse(inputs.MaxThreads); //ThreadPool.SetMinThreads(minThreads, minThreads); //ThreadPool.SetMaxThreads(maxThreads, maxThreads); if (inputs.SAccounts.Count == 0) { foreach (ListViewItem item in lstAccounts.Items) { item.SubItems[1].Text = "Waiting for accept verification"; item.BackColor = Color.Yellow; } var accountLogger = new AccountLogger(this, inputs.PhoneNumbers); accountLogger.OnAcceptListener += AccountLogger_OnAcceptListener; commenter = new Thread(() => { accountLogger.Execute(); }) { IsBackground = true }; commenter.Start(); } else { commenter = new Thread(() => { foreach (var account in inputs.SAccounts) { var commentSender = new CommentSender(this, account.Session, inputs.Posts, inputs.Comments, account.PhoneNumber); commentSender.Execute(); } }); commenter.IsBackground = true; commenter.Start(); } } catch (Exception ex) { MessageBox.Show(ex.Message, Globals.ErrorMessage_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); btnStop_Click(null, null); } }