Rohan Maity
04/13/2023, 2:11 PMviewModelScope, CoroutineScope implemented by the class
but it does not work with runBlocking
Whenever I call this suspend function runBlocking
on main thread callback never returns
But with other scopes it does
Has someone faced this situation where suspend callback never returns value
suspend fun suspendCallbackFun() : Boolean {
return suspendCoroutine {
actualCallbackFunction { error ->
if (error != null) {
// Does not come here with runBlocking {}
it.resume(false)
}else {
// Does not come here with runBlocking {}
it.resume(true)
}
}
}
}
Rohan Maity
04/13/2023, 2:12 PMrunBlocking
because this functions result need to be used in Java fileDmitry Khalanskiy [JB]
04/13/2023, 2:15 PMrunBlocking
blocks the thread it runs on until the block in it completes. So, the main thread can't do anything while this callback is awaited. Maybe this callback needs something to happen on the main thread, leading to a deadlock.Rohan Maity
04/13/2023, 2:16 PM