The sp_getapplock stored procedure has the following return values:
0: The lock was successfully granted synchronously.
1: The lock was granted successfully after waiting for other incompatible locks to be released.
-1: The lock request timed out.
-2: The lock request was canceled.
-3: The lock request was chosen as a deadlock victim.
-999: Indicates a parameter validation or other call error.
I am writing a wrapper for calling
sp_getapplock in our data access layer and I want to know under which circumstances -2 can be returned so that I can throw a descriptive and helpful exception. It is obvious what return values of -1 and -3 mean and I can easily create test conditions that cause those values to be returned. How would I manage to get a return value of -2?