Inconsistency in Parallel.ForEach : <p>I am using Parallel.foreach for more than 500 iterations.</p>

<p>My loop is something like:</p>

<pre><code>Parallel.ForEach(indexes, (index) =&gt;
 {

 //parentCreation with index object
 parent=create(index);

//call of function to create children
createChildrenOfType1(parent);
createChildrenOfType2(parent);
 });
</code></pre>

<p>I am facing inconsistent output. Parents are created correctly but child creation is inconsistent.
Sometimes no child is created, sometimes only few are created and so on.
Child creation method again has for loop to create 100s of children.</p>

<p>How can I make my child creation consistent while using the parallel foreach for parent creation.</p>
