Window is updated only in the end of this code. Use timer, or DoEvents before Sleep:
http://stackoverflow.com/questions/1...uivalent-for-c