Sign in to follow this  
Redp87

C# Trouble looping proxylist with account list in my checker.

Recommended Posts

Can sombody help me figure out how to do it?

 

First thing is: for example if the number of threads is 5, the problem is that it starts testing the accountList from 4 instead of 0. Secondly: I get duplicates of the last tested account and a lot of other duplicates!

 

   int accountPosition, accountPosition1, proxyPosition, proxyPosition1;

   //accountPosition1 = accountPosition + 1
   //proxyPosition = proxyPosition + 1


   [ThreadStatic]
   private static bool BanProxy = false;
   [ThreadStatic]
   private static bool DontR = false;
   [ThreadStatic]
   private static bool Dont = false;
   [ThreadStatic]
   private static bool Retry = false;

   public static List accountLst = new List();
   public static List proxyLst = new List();



private void Button2_Click(object sender, EventArgs e)
{
   int tCount = Convert.ToInt32(textBox2.Text);
   if (checkBox1.Checked)
      LoadProxies();
   LoadAccounts();

   for (int i = 0; i < tCount; i++)
   {
        var th = new Thread(() => Worker());
        th.Start();
   }
}
And here is the worker where the problem seems to come from. I tried everything I could think of without result.

   public void Worker()
   {
       int j = Thread.CurrentThread.ManagedThreadId;
       while (accountPosition < accountLst.Count - 1)
       {
           if (!DontR)
           {
               proxyCount++;
               if (label7.InvokeRequired)
                   Invoke((MethodInvoker)(() => this.label7.Text = $"pCount : {proxyCount}"));
           }
           if (proxyPosition1 == proxyLst.Count)
           {
               //Thread.Sleep(timetoretestproxylist);
               proxyPosition1 = 0;
           }
           proxyPosition = proxyPosition1;
           if (!DontR)
               proxyPosition1++;

           do
           {
               if (!Dont & !Retry)
               {
                    accountPostion = accountPostion1;
                    accountPostion1++;     
               }

               if (richTextBox2.InvokeRequired)
                   Invoke((MethodInvoker)(() => richTextBox2.AppendText($"accountPostion: {accountPostion}, thread: {j}" + "\n")));

               switch (Checker(accountLst[accountPostion], proxyLst[proxyPostion]))
               {
                   case FAIL_KEY:
                       failCount++;
                       BanProxy = false;
                       if (label3.InvokeRequired)
                           Invoke((MethodInvoker)(() => label3.Text = $"Bad : {failCount}"));
                       break;
                   case SUCC_KEY:
                       successCount++;
                       BanProxy = false;
                       Invoke(new MethodInvoker(() =>
                       {
                           label1.Text = $"Success : {successCount}";
                           richTextBox1.AppendText(accountLst[v] + "\n");
                       }));
                       break;
                   case FREE_KEY:
                       freeCount++;
                       BanProxy = false;
                       if (label2.InvokeRequired)
                           Invoke((MethodInvoker)(() => label2.Text = $"Free : {freeCount}"));
                       break;
                   case BAN_KEY:
                       banCount++;
                       if (label4.InvokeRequired)
                           Invoke((MethodInvoker)(() => label4.Text = $"Ban : {banCount}"));
                       BanProxy = true;
                       break;
                   case RET_KEY:
                       retCount++;
                       Retry = true;
                       break;
                   default:
                       unknownCount++;
                       BanProxy = false;
                       if (label7.InvokeRequired)
                           Invoke((MethodInvoker)(() => label5.Text = $"Unknown : {unknownCount}"));
                       break;
               }

               if (Retry)
               {
                   DontR = true;
                   break;
               }

               if (BanProxy)
               {
                   Dont = true;
                   break;
               }

               globalCount++;
               Invoke((MethodInvoker)(() =>
               {
                   richTextBox2.AppendText(accountLst[accountPostion] + "\n");
                   label6.Text = $"Total : {globalCount}/{accountLst.Count}";
               }));

               DontR = false;
               Dont = false;

           } while (accountPostion < accountLst.Count - 1);

       }
   }

 

BanProxy and Retry are switched off or on inside the checker.

Share this post


Link to post
Share on other sites

You need to make your code more readable. try to rename this

 

int r, g, v, w;

 

to the proper function of that variables, after that I may help you :)

Share this post


Link to post
Share on other sites

You need to make your code more readable. try to rename this

 

 int r, g, v, w;

 

to the proper function of that variables, after that I may help you :)

 

Thank you for your response. I modified the variables so they are more readable :)

Share this post


Link to post
Share on other sites

what men, you have 2 loops on the same variables. That code is really a mess.

 

while (accountPosition < accountLst.Count - 1)

 

and inside that you have

 

} while (accountPostion < accountLst.Count - 1);

 

you also do not initialize the variables,

Share this post


Link to post
Share on other sites

what men, you have 2 loops on the same variables. That code is really a mess.

 

while (accountPosition < accountLst.Count - 1)

     

and inside that you have

 

  } while (accountPostion < accountLst.Count - 1);

 

you also do not initialize the variables,

 

The variables can be initialized = 0 without changing anything. And the 2 loops are for rechecking the same account if the proxy is banned with proxy + 1.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this