halim
08/01/2019, 2:34 PMrunBlocking {
println("start main")
execute(coroutineContext) { println("some long operation") }
println("main done")
}
fun execute(context: CorouitneContext, action: suspend () -> Unit) {
action.startCorouitne(Continuation(context + <http://Dispatchers.IO|Dispatchers.IO>) {
println("corouitne complete")
})
}
so when execute :
start main
main done, i expected to see : corouitne complete
"startCorouitne" start a new coroutine in my case i bound it to runBlocking scope (with context as parent) and with dispather IO, so i expect to see "coroutine complete" in console ??
i think this new coroutne created by startCoroutine its not bound to runBlocking so when main is finish its ignore this corouitnelouiscad
08/01/2019, 2:53 PMstartCoroutine
if you use kotlinx.coroutines. Consider using withContext
or launch
instead, if needed.