sp_getapplock存储过程具有以下返回值:
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.
我正在编写一个在我们的数据访问层中调用sp_getapplock的包装器,我想知道在哪些情况下可以返回-2,这样我就可以抛出一个描述性和有用的异常.很明显-1和-3的返回值是什么意思,我可以很容易地创建导致返回这些值的测试条件.我如何设法获得-2的返回值?