I have a function that runs on main thread, which ...
# getting-started
l
I have a function that runs on main thread, which cannot be modified, like this:
Copy code
fun calculate(): Int
And inside it I need to call a suspend function. How to do that?
runBlocking
?
r
Depends whether completion of the suspend fun is required to determine the
Int
result
If so, you'll need
runBlocking
Otherwise consider passing a Scope and launching another coroutine as a side-effect
l
Thanks 😉
That suspend function is the underlying calculation on another thread
r
Well there's literally no reason to do it on another thread if you're going to block the main thread anyway