You need to acquire/release the semaphore permit on the processing thread, thus in the task, not outside.