brabo-hi
12/21/2021, 9:56 PMNick Allen
12/21/2021, 11:51 PMCancellationException
will be thrown from suspending methods.
override suspend fun doWork(): Result {
try {
doStuffInSuspendMethod()
return Result.success()
} catch (ce: CancellationException) {
handleCancellationSpecifically()
throw ce
}
}
I rarely need to do anything in response to cancellation specifically and usually just use a finally block.
There's also isActive
property on CoroutineScope
and CoroutineContext
.brabo-hi
12/22/2021, 12:33 AMisStopped