set the "task running" flag _before_ starting work on it, since it can take quite some time to finish and other instances will start in the mean time