- Sorry for the late reply, hope this can help someone. Since we cannot guarantee the moment of cancellation, and when this code can be hit, we need to use option A. Then, in the finally item, check whether the cancellation token was used or not. If it was used, do not release the semaphore.
Farjad
source share