You are currently viewing How do I launch a Swing coroutine?

How do I launch a Swing coroutine?

I want to launch a coroutine on Swing’s Event Dispatch thread. I have zero experience with Kotlin coroutines. Is the following correct, despite a “delicate API” warning popping up at GlobalScope?

button.addActionListener { GlobalScope.launch(Dispatchers.Main) { delay(1000) updateUiFoo(); delay(1000) updateUiBar(); delay(1000) updateUiBaz(); } } 

submitted by /u/fredoverflow
[link] [comments]