Sleeps for the given duration before resolving as .elapsed!. If the duration is negative or zero, resolves immediately.
Keep in mind that expressions evaluate concurrently in Par, so the following will NOT delay the printing of "Done":
let _ = Time.Sleep(Time.Second)
Debug.Log("Done") // executes immediately, does not wait
To delay subsequent code/computation, it is necessary to tie it to the resolution of .elapsed! via .case:
Time.Sleep(Time.Second).case {
.elapsed! => { Debug.Log("Done") } // waits for 1 second
}
Or without nesting:
Time.Sleep(Time.Second).case { .elapsed! => {} }
Debug.Log("Done")
Or in an expression:
// "Done" printed after one second
let ! = do { Time.Sleep(Time.Second).case { .elapsed! => {} } } in Debug.Log("Done")
// but this code here executes immediately, does not wait