juliocbcotta
04/12/2022, 12:32 PMrunBlocking(Dispatchers.Main.immediate) {
initialize(application)
}
suspend fun initialize(app: Application) = coroutineScope {
registry.groupBy { initializer ->
initializer.priority().ordinal
}
.toSortedMap()
.forEach { entry ->
val tasks = entry.value.map { initializer ->
async {
initializer.initialize(app)
}
}
tasks.awaitAll()
}
}
The code above runs, but if I change
async {
to
async(Dispatchers.Default) {
Makes the app blocks forever. Would anyone have an idea of how to fix it ?runBlocking
?