@Devv: Always code that way that you minimize cpu usage (and other ressources). Keep in mind that there are a lot of other processes run on your device. Constructing a real loop would use 100% cpu and you can imagine what happens then.
That is the reason why modern operating systems handle everything by events. An event is f.e. "Button pressed" or "Timer click". In walters example the os checks the wifi state every x seconds (maybe you want to reduce it from 30 to a lower value) seconds depending on your intention.