In your code snippet you put "with message" but you must make sure the actual code is "with messages"
A "wait" statement is blocking in LiveCode. The engine literally suspends all processes for the duration, which includes all other ongoing messages placed in the message queue by other handlers, as well as "housekeeping" tasks like keyboard polling and screen redrawing. Adding "with messages" tells LiveCode to release some processor cycles back to the engine for these other tasks, a sort of "interrupt" if you like.
This is often useful in a repeat loop. If you have a repeat loop that runs for a while, it may appear to lock up, as the loop is greedy and takes all the processor cycles. This can make your app unresponsive and appear to have crashed.
If you add a statement
inside the repeat loop, the engine can use that interruption to grab a few cycles to fire off screen updates and keyboard tests, etc.