Skip to content

Instantly share code, notes, and snippets.

@mayojava
Created October 26, 2018 10:25
Show Gist options
  • Select an option

  • Save mayojava/dfe1f4ff689caab557a88c019b37ec8d to your computer and use it in GitHub Desktop.

Select an option

Save mayojava/dfe1f4ff689caab557a88c019b37ec8d to your computer and use it in GitHub Desktop.
Non cancallable code
fun main() = runBlocking<Unit>{
launch {
withContext(NonCancellable) {
repeat(5) {
println("count: $it")
delay(500)
}
}
}
delay(100)
coroutineContext[Job]?.cancel()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment