Check for Connection While Running Code

In Semi-Automatic mode is it possible to search for a connection while the code is running? That is, I have a photon that I want to run the firmware on it if the stored WIFI connection is not available, but if the WIFI connection is available I want to stop running the code and have the device connect so that it can be controlled remotely.

Best case scenario is to control the device remotely, but if there is no signal the device will just default to running the code on the photon as normal in Semi-Automatic mode.

I feel like this should be possible, but wanted to see if anyone had thoughts around this scenario.

So… this?