Parallel Foreach sometimes getting stuck/freeze
<p>So my parallel foreach sometimes gets stuck and when debugging I try break all to see where I'm at and it's always on the beginning of the parallel foreach.
It doesn't do it every time but when it does it , it's after a while.</p>

<p>Can you guys help me out figure it out? I don't really understand why beside the fact that it could be because every threads are accessing the list of checkedPogos </p>

<pre><code>public static Task&lt;List&lt;string&gt;&gt; Checks(List&lt;string&gt; pogos)
{
    arret = false;

    var pogoTask= new Task&lt;List&lt;string&gt;&gt;(() =&gt;
    {
        List&lt;string&gt; checkedPogos= new List&lt;string&gt;();
        Parallel.ForEach(pogos, (string pogo, ParallelLoopState state) =&gt;
        {
                if (arret)
                    state.Stop();
                pogo= pogo.Trim();
                if (pogo != null &amp;&amp; Check(pogo))
                {
                    checkedPogos.Add(pogo);
                }
        });
        return checkedPogos.Distinct().ToList();
    });
    pogoTask.Start();
    return pogoTask;
}
</code></pre>

<p>EDIT : I've changed the List to a concurrent collection and it still didn't fix the problem.</p>