google-developer-training / basic-android-kotlin-compose-training-race-tracker

Apache License 2.0
32 stars 35 forks source link

Android Basics: Introduction to Coroutines in Android Studio #17

Open jzheng23 opened 10 months ago

jzheng23 commented 10 months ago
suspend fun run() {
    try {
        while (currentProgress < maxProgress) {
            delay(progressDelayMillis)
            currentProgress += progressIncrement
        }
    } catch (e: CancellationException) {
        Log.e("RaceParticipant", "$name: ${e.message}")
        throw e // Always re-throw CancellationException.
    }
}

Cannot catch an error