waitOrNull
Returns the next event from the queue, waiting up to timeout for one to arrive, or null when none arrives in time. Duration.INFINITE waits until an event arrives.
Use it instead of pollOrNull in a loop that has nothing to do between events. The wait can run past timeout by the system's scheduling delay. timeout must not be negative.
Throws
if timeout is negative.