withContext

suspend fun <T> withContext(
    context: CoroutineContext,
    block: suspend CoroutineScope.() -> T
): T
(source)

Calls the specified suspending block with a given coroutine context, suspends until it completes, and returns the result.

This function immediately applies dispatcher from the new context, shifting execution of the block into the different thread inside the block, and back when it completes. The specified context is added onto the current coroutine context for the execution of the block.