Calling the sleep function blocks the current thread for at least the given time (time accuracy depends on the system-clock).
If you don't want the application to freeze during that time you have to
a) sleep and check your condition in another thread
b) check your condition in a repeatedly called method (such as "OnUpdate" in UI-Components) without using sleep
If you decide to go with option a), keep in mind that shared objects may bei changed by the main thread during your condition check and action
If you decide to go with option b), keep in mind that the condition check and the following action will also block the application during execution
|