<@U0H8K7DEV> Here comes the code. You provide inBa...
# coroutines
u
@Ian Here comes the code. You provide inBackground(), main demonstrates how your users should apply it:
Copy code
fun inBackground(doWork: suspend () -> Unit) {
    launch(CommonPool) {
        try {
            doWork()
        } catch (t: Throwable) {
            // Do Logging, rethrow, ...
        }
    }
}

fun main(args: Array<String>) {
    inBackground {
        println("before delay")
        delay(100)
        println("after delay")
    }
    Thread.sleep(100000)
}
Ideally, inBackground() should be inline. But that is not yet supported.
👍 3
i
Thank you Uli! I have moved this code into my codebase and will be testing it.