This is what my loop looks like:
var loopResult = Parallel.ForEach(folder.Items.Cast<object>(), (item, loopState) =>
{
if (!loadData)
{
loopState.Stop();
return;
}
DoSomeWork(item);
}
);
if (loopResult.IsCompleted)
{
Debug.WriteLine("done");
}
The problem is the code never gets to if (loopResult.IsCompleted). After executing return; for all the different threads, absolutely nothing happens.
DoSomeWork?