Spark.function() interrups code or runs in parallel?

Hey!

It might be a obvious but I have not found in the forum and in the documentation. If I define a spark.function() that turns on a led when it is called, will it interrupt the process that spark core was doing or will it run in parallel?

Thanks.

@lia, when used, Spark.function() runs a function defined by the user. That function is called by the background task and should be kept relatively short. The reason for that is that when loop() “finishes”, control returns to the background task (where it calls the function from Spark.function) and when its done, it goes back to loop() again. Controlling an LED is quick so that’s fine. Typically, setting flags that the user loop() code acts upon is done.

All this to say that nothing runs in “parallel”, just a big loop. :smile:

2 Likes