Chills
02/09/2020, 3:57 PMdiesieben07
02/09/2020, 3:58 PMlaunch coroutine never suspends, so the cancelAndJoin is only ever reached when the launch coroutine is complete. This is because you are inside a runBlocking context, which means there is only one thread executing all coroutines in an event loop.diesieben07
02/09/2020, 3:58 PMdelay(100) instead of Thread.sleep you should see the expected result.diesieben07
02/09/2020, 4:06 PMisActive == false because cancellation is handled transparently by delay (or even Thread.sleep through interrupts).
If you want to detect cancellation you'd have to use try-finallyChills
02/09/2020, 4:16 PMdiesieben07
02/09/2020, 5:17 PMCancellationExceptionZach Klippenstein (he/him) [MOD]
02/09/2020, 8:12 PM