Hey,
so got a new problem...
I'm writing a multithreaded proxychecker in c#.
I'm using BackgroundWorkers to solve the multithreading problem.
But i have problems coordinating and assigning the proxys left in queue to the runnning workers. It works most of the time but sometimes no result comes back so some proxys get 'lost' during the process.
This list represents the queue and is filled with the ids of the proxys in a ListView.
private List<int> queue = new List<int>();
private int GetNextinQueue()
{
if(queue.Count > 0)
{
lock (lockqueue)
{
int temp = queue[0];
queue.Remove(temp);
return temp;
}
}
else
return -1;
}
Above is my method to get the next proxy in queue, i'm using the lock statement to prevent race conditions but i am unsure if its enough or whether it slows the process down because it makes the other threads wait... (lockqueue is an object just used for locking)
So my question is, how is it possible that some proxys are not getting checked(even if the ping fails the checking should return something, but sometimes theres just nothing) and how i can i optimize this code for performance?
Here's the rest of the code which i consider important for this question http://pastebin.com/iJduX82b
If something is missing just write a comment
Thanks :)