Tell me please. I create a stream using  CreateThr...
# kotlin-native
r
Tell me please. I create a stream using  CreateThread (winapi), trying to call it GetForegroundWindow is also from winapi. But the program is cut down, and without errors. The same code, without a stream, works like a stream without this function. Tried to call the function "initRuntimeIfNeeded ()", did not help
t
The main thread has to wait for the other thread. You need to sleep (or WaitForSingleObject) in your
main
function, the one that calls CreateThread.
And I don't think you can mutate the
exit
variable like that. You should probably take a look here: https://kotlinlang.org/docs/reference/native/concurrency.html
r
Should I insert "sleep (or WaitForSingleObject)" after "while"? I'm not sure this will work. And if before "while", as I understand it, then "while" does not start, because the flow is eternal
For the link to the documentation about the annotations, thanks, I did not know about it
Why GetForegroundWindow cuts down my program