Skip to content

Instantly share code, notes, and snippets.

@tkuenneth
Created January 8, 2021 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkuenneth/a9c83043254c35e6549b90bbae6e05b1 to your computer and use it in GitHub Desktop.
Save tkuenneth/a9c83043254c35e6549b90bbae6e05b1 to your computer and use it in GitHub Desktop.
A short demo using coroutines
package com.thomaskuenneth
import androidx.compose.desktop.Window
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
fun main() = Window {
Box(contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()) {
Button(onClick = {
GlobalScope.launch {
while (isActive) {
// while (true) {
println("ohoho...")
}
}
}) {
Text("Hallo")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment