Putting an Electron to Sleep until a condition is met

I see you opened a new thread for this, so I'll lock this thread to avoid scattering replies over multiple threads.
The discussion should be continued in the new thread