Sleep has nothing to do with threading.
Please make it simpler to help you and post the relevant code directly.
Watch the resumable subs video tutorial:
https://www.b4x.com/etp.html
It is critical to understand how it works.
You cannot use Wait For inside this sub (at least not without checking for reentrances).