Looking for a Special Delay Library

I now see something wrong. The while loop is basically a delay. It needs to wait until it's out of the while loop until it can continue.