Jump to content

Problem - MutliThreading With List

- - - - -

  • Please log in to reply
4 replies to this topic

#1
globus25

globus25

    Newbie

  • Members
  • Pip
  • 6 posts
I made proxy checker that works on multithreading through Task.Factory but there is one problem because I setup "bots" to 10 and always must click one more time button to check another 10 proxies.
I convert proxy list from listbox to List(List<string> etc.)
Could someone show me resolve to that problem or some pseudocode so I can write my own?

Here is how I start 10" bots":


Task[] check= new Task[10];

            for (int i = 0; i < 10; i++)

            {

                check[i] = Task.Factory.StartNew(() =>

                    {

                        checkProxy();

                    });

            }
Part 2 - checkProxy() code:

private void checkProxy()

{

	pBOT++; // current number in List

	string[] proxy=proxies[pBOT];

	/////////////////////////

	////Processing proxy

	/////////////////////////

}

  

And I need it to process the rest of proxies continually without me clicking again.

different explanation:

I have 30 names in list... I start 10 threads in loop(for) to process first 10 names... but when that for is finished there is 20 unprocessed names...

so how to make thread to go after another name?

PS. please be easy on post like : "U don`t know what U doing etc." - I`m asking because the multitasking is only problem for me...

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
I'm assuming pBOT is a global variable being shared by the threads. I think you would do better to pass the proxy to checkProxy as a parameter, so that only the main thread is responsible for handing out the proxies to check and knowing which one is next. You could also send checkProxy three proxies to check, so that each one knows at startup which three it will be responsible for.

Failing that, you will need to start looking at mutex's and locks on your proxies array and pBOT global variable to ensure that threads don't try to use pBOT at the same time and result in two increments followed by two accesses of the same proxy.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
globus25

globus25

    Newbie

  • Members
  • Pip
  • 6 posts

WingedPanther said:

I'm assuming pBOT is a global variable being shared by the threads. I think you would do better to pass the proxy to checkProxy as a parameter, so that only the main thread is responsible for handing out the proxies to check and knowing which one is next. You could also send checkProxy three proxies to check, so that each one knows at startup which three it will be responsible for.
I made it this way but still this doesn`t solve my problem about stopping after 10 bots in my case

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Do you mean your bots aren't stopping, or something else?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
globus25

globus25

    Newbie

  • Members
  • Pip
  • 6 posts
already figured it out :)

Thread with getting next proxy
that next proxy - has at the end function for checking

that way it works to the end of the list




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users