问题 I'm having some trouble using Parallel.ForEach. I need to simulate a couple of hardware components, that wait for an incoming connection, and reply to it. My current code is as follows: Task.Factory.StartNew(() => components, (component) => { var listener = new TcpListener(component.Ip, component.Port); while(true) { using(var socket = listener.AcceptSocket()) { //Read out socket and send a reply socket.Close(); } } }); The problem I'm having is: Not every component will get his own thread