It could be getting optimised out

The most likely explanation is that your program is stuck inside that loop, which means that it is no longer able to perform its message loop, thus freezing the application. This is why you use SetTimer, because it runs in an external thread, your program can update itself without worrying about this.