sql-server - 带有 WAITFOR DELAY 的过程直到最后才会执行
问题描述
我有一个程序,基本上用于某个任务的超时。用户必须在 3 分钟内完成此任务,否则他们将失败。这是它的样子:
--Perform an insert statement that notifies the user that they have 3 minutes to finish this task
WAITFOR DELAY '00:00:30'
IF EXISTS(SELECT*FROM _Users WHERE UserID=@UserID AND isDone=0)
--Perform another insert statement that notifies the user that they have 2 minutes 30 seconds remaining to finish this task
WAITFOR DELAY '00:00:30'
IF EXISTS(SELECT*FROM _Users WHERE UserID=@UserID AND isDone=0)
--Perform another insert statement that notifies the user that they have 2 minutes remaining to finish this task
WAITFOR DELAY '00:00:30'
IF EXISTS(SELECT*FROM _Users WHERE UserID=@UserID AND isDone=0)
--Perform another insert statement that notifies the user that they have 1 minute 30 seconds remaining to finish this task
WAITFOR DELAY '00:00:30'
IF EXISTS(SELECT*FROM _Users WHERE UserID=@UserID AND isDone=0)
--Perform another insert statement that notifies the user that they have 1 minute remaining to finish this task
WAITFOR DELAY '00:00:30'
IF EXISTS(SELECT*FROM _Users WHERE UserID=@UserID AND isDone=0)
--Perform another insert statement that notifies the user that they have 30 seconds remaining to finish this task
WAITFOR DELAY '00:00:20'
IF EXISTS(SELECT*FROM _Users WHERE UserID=@UserID AND isDone=0)
--Perform another insert statement that notifies the user that they have 10 seconds remaining to finish this task
WAITFOR DELAY '00:00:10'
IF EXISTS(SELECT*FROM _Users WHERE UserID=@UserID AND isDone=0)
--Perform another insert statement that notifies the user that they have failed to complete the task within the required time frame.
但由于某种原因,程序总是在剩下 1 分钟时停止。我注意到,当我手动执行此过程时,它工作得很好,但是当我通过另一个过程也由另一个过程执行的另一个过程执行时,它会在剩下 1 分钟时停止。
有什么我做错了,有没有更好的方法来做到这一点?
PS:我不拥有执行这个程序的应用程序的源代码,我也不能要求任何修改来处理源代码中的超时,因此,我必须用一个程序来做。
解决方案
推荐阅读
- javascript - 获取firebase数据后异步函数不返回值
- woocommerce - Woocommerce 强制更新数据库卡住
- php - Is it possible get table structures of a .frm file using PHP?
- javascript - 如何将变量传递给javascript中的正则表达式?
- c# - mvc按钮避免页面刷新而不使用ajax
- reactjs - redux:在异步获取和文档创建后重新渲染组件
- python - python flask app运行失败(404、405响应码)
- ios - 快速从应用程序打开图库
- c++ - C++ error C2440: 'initializing': cannot convert from 'class name' to 'same class name'
- ios - iOS 高变基/绑定时间