I saw this post where it uses this event and I would like to know if there is any similar alternative in Kotlin, since I would like to use the WaitOne method that it uses for the return.
Example code:
fun exampleMethod(): String{
var command = "example string"
//do someting with this string
return command
}
I want to run this method continuously and receive the value of my variable command of the return every time it runs on the loop.
So I just ran into a situation like this and was missing my good old
AutoResetEvent. Kotlin does have great coroutine controls like Flows that can be used for signalling. I made a class that wraps this design pattern so its purpose is easier to read when used.Let me know if you can see any issues with the implementation. I tried making an AutoSyncSignal, but I ran into a lot of issues trying to get the first awaiting coroutine to reset the signal without getting dead-locked.
You can try it on the Kotlin Playground