I'm not sure how the internal thread handling of Parallel.foreach works and whether it can guarantee that a construct like this would work?
Parallel.Foreach(Connections, c =>
{
Input in = c.getInput();
while (in.hasNext()) {
object o = in.getNext();
dosomething(o);
}
}
);
where in.hasNext() just waits for an object in the input stream and returns true. Basically can I run a bunch of infinite while loops in a parallel foreach structure whilst guaranteeing that they will all run at the same time.
(For the brave, can I adjust this so I can edit the connection list by adding (and removing, which should be trivial) connections and it will still read input from all connections in the list).