In this code if i remove the (Debug.Log();) the foreach stop working, any ideia why?

int threadCount = chunkThread.Length;

    do //Clean the Thread List and get the BoardGrid List in one ArrayList .
    {
        foreach (ChunkThread tempThread in chunkThread)
        {
            if (tempThread.isRunning == false)
            {
                boardGrid.Add(tempThread.returnBoardGrid());
                threadCount--;
            }
            else
            {
                new WaitForEndOfFrame();
            }
        }
    }while (threadCount > 0);

    Debug.Log(""); ****----> If i remove this line the foreach below doens´t work****

    foreach (List<TileObj> tempGrid in boardGrid)
    {
        StartCoroutine(boardInstanciateChunk(tempGrid));
        new WaitForEndOfFrame();
    }

    Debug.Log(Time.realtimeSinceStartup);
}

}

Sorry, but I did not get, I am not using a While looping there, I am using the Do-While, if I use {} after I got an error saying “;” expected. I checked on MSDN lib, the syntax looks correct, can you show me the error? Thanks for your time.

If you remove the debug.log(“”), the foreach loop becomes part of the while loop (meaning it will only execute if the while loop does). Remove the while loop also and it should work.