Since the SPARK_WLAN_Loop() function is not documented I made it like that:
if (!Spark.connected()) {
Spark.connect(); // Establish connection to the cloud
delay(10000); // Give the connection some time to settle to connectivity
while (!Spark.connected()) {
RGB.color(255,0,0); // Set Core LED to false (red) to get visual feedback that we currently have no connectivity
Spark.connect(); // While we are in the loop try to connect (in case internet is back)
digole.clearScreen(); // User code not running, to not waste energy clear the display
delay(60000); // This is a worst-case scenario, let´s pause the game for 60 seconds
}
} else {
// running threads
}
Tested - works and delays() in that example are ok for me. Because this code will only be executed if we have no connection