Why does this Parallel.ForEach code freeze the program up? <p>More newbie questions: </p> <p>This code grabs a number of proxies from the list in the main window (I couldn't figure out how to make variables be available between different functions) and does a check on each one (simple httpwebrequest) and then adds them to a list called finishedProxies.</p> <p>For some reason when I press the start button, the whole program hangs up. I was under the impression that Parallel creates separate threads for each action leaving the UI thread alone so that it's responsive?</p> <pre><code>private void start_Click(object sender, RoutedEventArgs e) { // Populate a list of proxies List&lt;string&gt; proxies = new List&lt;string&gt;(); List&lt;string&gt; finishedProxies = new List&lt;string&gt;(); foreach (string proxy in proxiesList.Items) { proxies.Add(proxy); } Parallel.ForEach&lt;string&gt;(proxies, (i) =&gt; { string checkResult; checkResult = checkProxy(i); finishedProxies.Add(checkResult); // update ui /* status.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate() { status.Content = "hello" + checkResult; } )); */ // update ui finished //Console.WriteLine("[{0}] F({1}) = {2}", Thread.CurrentThread.Name, i, CalculateFibonacciNumber(i)); }); } </code></pre> <p>I've tried using the code that's commented out to make changes to the UI inside the Parallel.Foreach and it makes the program freeze after the start button is pressed. It's worked for me before but I used Thread class.</p> <p>How can I update the UI from inside the Parallel.Foreach and how do I make Parallel.Foreach work so that it doesn't make the UI freeze up while it's working?</p> <p><a href="http://pastie.org/2958219">Here's the whole code.</a></p>