For the SD side of things you might like to readup on this
https://docs.particle.io/reference/firmware/photon/#transfer-void-em-void-em-size_t-std-function-
This also provides a way to supply callback function when done.
And if you want to use a similar aproach for other things, you can have a look in the open source repo, how the SPI is implemented.
Another aproach would be multi threading
e.g. look here
Particle Photon multi blink sample using threads