I have list of batches to process. forever.
I want to do each chunk (5) in parallel, and when it is done move to the next chunk.
for some reason, the code bellow is not waiting for the chunk to be done and continue even if it is not completed.
while (true)
{
foreach (string[] urlsArr in chunks)
{
int i = 0;
foreach (var url in urlsArr)
{
ThreadPool.QueueUserWorkItem(x =>
{
ProccessUrl(url, config, drivers[i]);
_resetEvent.Set();
i++;
});
}
_resetEvent.WaitOne();// this is not really waiting.
}
}