Multithreaded proxy checker
So I started writing proxy checker, I figured out responses from proxyjudge etc. but next step makes my head hurts...
Multithreading based on 20 connections at time with replacing finished with new one...
So basically Im trying to create 20 threads that will work on connect function.
I already tried 2 function with threading like this(pseudocode) ->
Code:
Thread[] ts=new Thread[20]
for(i=0;i<20;i++)
ts[i]=new Thread(connect)
ts[i].start()
But in that method I couldn`t figure out how to make them work on next proxies with return stuff, so I tried to make "connect" to return the class(structure) with results, 2 fails in this method -> couldn`t get like i said to go with next 20 proxies, could get results in proper way
2nd function ->
I used threadpool but I could make it asynchronous to make thread wait for return from httpwebrequest...
If anyone have idea how to deal with that please post it:)
ps. I want to make something similar to "Charon" -> project2025 site
Re: Multithreaded proxy checker
I'm not quite sure what you are asking?
For managing threads, I would probably use 21 threads, one thread as the parent that manages the other 20.
For example (this won't compile, I'm just giving you ideas):
Code:
Thread[] ts = new Thread[20]
for(i=0;i<20;i++)
{
ts[i]=new Thread(new ThreadStart(connect))
ts[i].start()
}
while(true)
{
foreach(Thread thrd in ts)
{
if(!thrd.IsAlive)
{
thrd.Abort();
thrd = new Thread(new ThreadStart(connect));
}
}
}
I will get back to you with a more appropriate implementation once I get home, but I would love some more information on what you want, exactly. :confused:
-jD
Re: Multithreaded proxy checker
Thanks for replying... in short I will explain:)
20x threads working on 1 proxy each...
I made other class for checking proxies... so I need a method to return status of proxy from thread,,, I tried to make something like this :
Code:
public Result(class with results below) connect()
{
//checking
}
public Result()
{
public string result{get;set;}
public int counter {get;set} /// counter gives the 1 if proxy processed 0 if something was wrong, if 0 then proxy will be processed one more time
}
Re: Multithreaded proxy checker
EDIT: OMG IM SO STUPID! -.- Sorry, I have been writing VB all day!
-jD
Re: Multithreaded proxy checker
vb Code:
Thread[] ts = new Thread[20]
for(i=0;i<20;i++)
{
ts[i]=new Thread(new ThreadStart(connect))
ts[i].start()
}
while(true)
{
foreach(Thread thrd in ts)
{
if(!thrd.IsAlive)
{
thrd.Abort();
thrd = new Thread(delegate() { var someValue = connect(); });
MessageBox.Show((string)someValue);
}
}
}
Try that... Just an Idea though :P
-jD
Re: Multithreaded proxy checker
Okey I will test it today and reply :)
Re: Multithreaded proxy checker
Quote:
Originally Posted by
jduncanator
vb Code:
Thread[] ts = new Thread[20]
for(i=0;i<20;i++)
{
ts[i]=new Thread(new ThreadStart(connect))
ts[i].start()
}
while(true)
{
foreach(Thread thrd in ts)
{
if(!thrd.IsAlive)
{
thrd.Abort();
thrd = new Thread(delegate() { var someValue = connect(); });
MessageBox.Show((string)someValue);
}
}
}
Try that... Just an Idea though :P
-jD
Yours code won`t work because connect must return something and in first loop won`t start...
Re: Multithreaded proxy checker
I know... i was giving ideas, not code
-jD