What am I misunderstanding about K/N Coroutines th...
# kotlin-native
a
What am I misunderstanding about K/N Coroutines that is preventing this from ever running:
Copy code
fun startUiLoop() {
    GlobalScope.launch {
        delay(32L)
        updateUi()
    }
}
My end goal is to get this to pull data 30 times per second and update my GUI with it, without blocking anything. If further context helps, it's built using: https://github.com/msink/kotlin-libui
d
I don't think
delay
works on native atm.
s
it's only going to run once before stopping, you're not looping anything
1
n
Did you try replacing delay with sleep (from Kotlin Native's Posix library)? The sleep function ( https://en.wikibooks.org/wiki/C_Programming/POSIX_Reference/unistd.h/sleep ) will only be available when targeting Linux or MacOS platforms.
a
@serebit Should I just have
updateUi()
call
startUiLoop()
and create a new coroutine every time? Also it's not even running once, debugging Cinterop has been a struggle.
o
sleep
is blocking sleep and is not compatible with coroutines, ask on #coroutines