Using multithreading for loop
- by annelie
Hello,
I'm new to threading and want to do something similar to this question:
http://stackoverflow.com/questions/100291/speed-up-loop-using-multithreading-in-c-question
However, I'm not sure if that solution is the best one for me as I want them to keep running and never finish. (I'm also using .net 3.5 rather than 2.0 as for that question.)
I want to do something like this:
foreach (Agent agent in AgentList)
{
// I want to start a new thread for each of these
agent.DoProcessLoop();
}
---
public void DoProcessLoop()
{
while (true)
{
// do the processing
// this is things like check folder for new files, update database
// if new files found
}
}
Would a ThreadPool be the best solution or is there something that suits this better?
Thanks,
Annelie