Add a sempahore to make cancelProcessing a synchronous method.