My iOS Swift app performs some lengthy (a second or more) calculations based on inputs from a number of sliders. I would like to restart the calculation every time a slider is moved and an input parameter is changed. This means, I guess, that the calculation needs to happen on a background thread, but what's the best way to stop and restart the calculation? If I kill the background thread each time, I could end up restarting it hundreds of times. How can I avoid using excessive memory with recreating objects?
Thanks,
Julian