public void AddAccountVerificationLogger(string log) { try { if (LstBoxLogger_AccountVerification.Items.Count > 1000) { LstBoxLogger_AccountVerification.Invoke(new MethodInvoker(delegate { LstBoxLogger_AccountVerification.Items.Clear(); })); } if (LstBoxLogger_AccountVerification.InvokeRequired) { LstBoxLogger_AccountVerification.Invoke(new MethodInvoker(delegate { LstBoxLogger_AccountVerification.Items.Add(log); LstBoxLogger_AccountVerification.SelectedIndex = LstBoxLogger_AccountVerification.Items.Count - 1; })); } else { LstBoxLogger_AccountVerification.Items.Add(log); LstBoxLogger_AccountVerification.SelectedIndex = LstBoxLogger_AccountVerification.Items.Count - 1; } } catch { } }
private void btnAccountVerification_AccountVerification_Click(object sender, EventArgs e) { CheckNetConn = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable(); if (CheckNetConn) { try { LstBoxLogger_AccountVerification.ClearSelected(); int NoofThread = 5; IsStop = false; if (NumberHelper.ValidateNumber(textNoofThread_AccountVerification.Text.Trim())) { NoofThread = int.Parse(textNoofThread_AccountVerification.Text.Trim()); ThreadPool.SetMaxThreads(NoofThread, 5); } else { AddAccountVerificationLogger("[ " + DateTime.Now + " ] => [ Please Fill Integer value in TextBox(No. of Threads) ]"); MessageBox.Show("Please Fill Integer value in TextBox(No. of Threads) "); textNoofThread_AccountVerification.Text = "5"; return; } counter_AccVerification = lstEmailVerification_AccountVerification.Count(); btnAccountVerification_AccountVerification.Cursor = Cursors.AppStarting; if (lstEmailVerification_AccountVerification.Count > 0) { foreach (string account in lstEmailVerification_AccountVerification) { ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyAccountMultiThread), new object[] { account }); } } else { AddAccountVerificationLogger("[ " + DateTime.Now + " ] => [ Please Load Account ! ]"); } } catch (Exception ex) { Console.WriteLine("Error >>> " + ex.StackTrace); } } else { MessageBox.Show("Your Internet Connection is disabled ! or not working, Please Check Your Internet Connection..."); AddAccountVerificationLogger("[ " + DateTime.Now + " ] => [ Your Internet Connection is disabled ! or not working, Please Check Your Internet Connection... ]"); } }