<@U0H8K7DEV> Is this what you are looking for: ```...
# coroutines
u
@Ian Is this what you are looking for:
Copy code
fun inBackground(doWork: suspend () -> Unit) {
    launch(Unconfined) {
        try {
            doWork()
        } catch (t: Throwable) {
            // Do Logging, rethrow, ...
        }
    }
}

// Example showing thread and execution order of inBackground/future combination
// Don't use Thread.sleep in production. Just used to not get distracted by delay() suspension
fun main(args: Array<String>) {
    inBackground {
        Thread.sleep(100)
        println("${Thread.currentThread().name}: before future")
        future {
            Thread.sleep(100)
            println("${Thread.currentThread().name}: in future")
        }.await()
        Thread.sleep(100)
        println("${Thread.currentThread().name}: after future")
    }
    println("${Thread.currentThread().name}: returned")
    Thread.sleep(100000)
}
Which results in:
Copy code
main: before future
main: returned
ForkJoinPool.commonPool-worker-1: in future
ForkJoinPool.commonPool-worker-1: after future