Use an atomic loop handler

See http://bit.ly/12slFCo for details.