blob: 8c57b42903d35c493aba44e70052c074cd53f298 [file] [log] [blame]
Roman Elizarov8b38fa22017-09-27 17:44:31 +03001/*
Roman Elizarov660c2d72020-02-14 13:18:37 +03002 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Roman Elizarov8b38fa22017-09-27 17:44:31 +03003 */
4
Roman Elizarov660c2d72020-02-14 13:18:37 +03005// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit.
6package kotlinx.coroutines.guide.exampleCancel07
Roman Elizarov8b38fa22017-09-27 17:44:31 +03007
Roman Elizarov0950dfa2018-07-13 10:33:25 +03008import kotlinx.coroutines.*
Roman Elizarov8b38fa22017-09-27 17:44:31 +03009
Prendota65e6c8c2018-10-17 11:51:08 +030010fun main() = runBlocking {
Roman Elizarov8b38fa22017-09-27 17:44:31 +030011 val result = withTimeoutOrNull(1300L) {
12 repeat(1000) { i ->
13 println("I'm sleeping $i ...")
14 delay(500L)
15 }
16 "Done" // will get cancelled before it produces this result
17 }
18 println("Result is $result")
Roman Elizarov8b38fa22017-09-27 17:44:31 +030019}