We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 39107ee commit e321394Copy full SHA for e321394
ui/kotlinx-coroutines-android/src/HandlerDispatcher.kt
@@ -120,9 +120,11 @@ internal class HandlerContext private constructor(
120
}
121
122
override fun scheduleResumeAfterDelay(timeMillis: Long, continuation: CancellableContinuation<Unit>) {
123
- handler.postDelayed({
+ val block = Runnable {
124
with(continuation) { resumeUndispatched(Unit) }
125
- }, timeMillis.coerceAtMost(MAX_DELAY))
+ }
126
+ handler.postDelayed(block, timeMillis.coerceAtMost(MAX_DELAY))
127
+ continuation.invokeOnCancellation { handler.removeCallbacks(block) }
128
129
130
override fun invokeOnTimeout(timeMillis: Long, block: Runnable): DisposableHandle {
0 commit comments