delay

suspend fun delay(timeMillis: Long): Unit (source)

Delays coroutine for a given time without blocking a thread and resumes it after a specified time.

This suspending function is cancellable. If the Job of the current coroutine is cancelled or completed while this suspending function is waiting, this function immediately resumes with CancellationException. There is a prompt cancellation guarantee. If the job was cancelled while this function was suspended, it will not resume successfully. See suspendCancellableCoroutine documentation for low-level details.

If you want to delay forever (until cancellation), consider using awaitCancellation instead.

Note that delay can be used in select invocation with onTimeout clause.

Implementation note: how exactly time is tracked is an implementation detail of CoroutineDispatcher in the context.

Parameters

timeMillis - time in milliseconds.

suspend fun delay(duration: <ERROR CLASS>): Unit (source)

Delays coroutine for a given duration without blocking a thread and resumes it after the specified time.

This suspending function is cancellable. If the Job of the current coroutine is cancelled or completed while this suspending function is waiting, this function immediately resumes with CancellationException. There is a prompt cancellation guarantee. If the job was cancelled while this function was suspended, it will not resume successfully. See suspendCancellableCoroutine documentation for low-level details.

If you want to delay forever (until cancellation), consider using awaitCancellation instead.

Note that delay can be used in select invocation with onTimeout clause.

Implementation note: how exactly time is tracked is an implementation detail of CoroutineDispatcher in the context.