作为我的安装程序的一部分,我需要调用 DBMS 系统并将其关闭,然后再启动它。如果该 DBMS 由于某种原因挂起,我的安装程序将永远挂起。我调用 Exec 来启动或停止数据库的命令,我的问题是:
ewWaitUntilIdle 的具体定义是什么?如果我启动/停止数据库的命令永远不会返回,什么满足空闲条件?
作为我的安装程序的一部分,我需要调用 DBMS 系统并将其关闭,然后再启动它。如果该 DBMS 由于某种原因挂起,我的安装程序将永远挂起。我调用 Exec 来启动或停止数据库的命令,我的问题是:
ewWaitUntilIdle 的具体定义是什么?如果我启动/停止数据库的命令永远不会返回,什么满足空闲条件?
这是来自 Inno 来源的确切代码:
procedure HandleProcessWait(ProcessHandle: THandle; const Wait: TExecWait;
const ProcessMessagesProc: TProcedure; var ResultCode: Integer);
begin
try
if Wait = ewWaitUntilIdle then begin
repeat
ProcessMessagesProc;
until WaitForInputIdle(ProcessHandle, 50) <> WAIT_TIMEOUT;
end;
if Wait = ewWaitUntilTerminated then begin
{ Wait until the process returns, but still process any messages that
arrive. }
repeat
{ Process any pending messages first because MsgWaitForMultipleObjects
(called below) only returns when *new* messages arrive }
ProcessMessagesProc;
until MsgWaitForMultipleObjects(1, ProcessHandle, False, INFINITE, QS_ALLINPUT) <> WAIT_OBJECT_0+1;
{ Process messages once more in case MsgWaitForMultipleObjects saw the
process terminate and new messages arrive simultaneously. (Can't leave
unprocessed messages waiting, or a subsequent call to WaitMessage
won't see them.) }
ProcessMessagesProc;
end;
{ Get the exit code. Will be set to STILL_ACTIVE if not yet available }
if not GetExitCodeProcess(ProcessHandle, DWORD(ResultCode)) then
ResultCode := -1; { just in case }
finally
CloseHandle(ProcessHandle);
end;
end;
如您所见,ewWaitUntilIdle 仅使用WaitForInputIdle函数-在此处查看更多信息:http: //msdn.microsoft.com/en-us/library/windows/desktop/ms687022%28v=vs.85%29.aspx