Using multithreading for loop
Posted
by annelie
on Stack Overflow
See other posts from Stack Overflow
or by annelie
Published on 2010-04-29T15:23:17Z
Indexed on
2010/04/29
15:27 UTC
Read the original article
Hit count: 321
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
© Stack Overflow or respective owner