Problem with while loop looping infinitely

Okay my while loop is going on forever and im not sure why. This is the list I am accessing in this script

public List<int> usedTiles = new List<int>(); 

And here is the while loop within the other script.
Everything is linking properly as far as I know but it simply loops forever. There must be something very obvious that I am not seeing but I’m sure you guys will.

int tileIndex = UnityEngine.Random.Range (0, 8);
while (levelGenerator.usedTiles.Contains (tileIndex))
{
     tileIndex = UnityEngine.Random.Range (0, 8);
}

Try listing your code in the update() function and change ‘while’ to ‘if’ that should automatically update the code and test if the used tiles contains the tile index. Hope this helps