由於我的安裝程序的一部分,我需要調用出一個DBMS系統,並關閉它,再後來啓動它。如果該DBMS由於某種原因掛起,我的安裝程序將永久掛起。我打電話Exec能夠將啓動或停止數據庫的命令,我的問題是:在Inno Setup中,ewWaitUntilIdle的精確定義是什麼?
到底是什麼ewWaitUntilIdle的定義是什麼?如果我的命令啓動/停止數據庫永遠不會返回,那麼滿足閒置狀態的條件是什麼?
由於我的安裝程序的一部分,我需要調用出一個DBMS系統,並關閉它,再後來啓動它。如果該DBMS由於某種原因掛起,我的安裝程序將永久掛起。我打電話Exec能夠將啓動或停止數據庫的命令,我的問題是:在Inno Setup中,ewWaitUntilIdle的精確定義是什麼?
到底是什麼ewWaitUntilIdle的定義是什麼?如果我的命令啓動/停止數據庫永遠不會返回,那麼滿足閒置狀態的條件是什麼?
這是創新科技的來源確切代碼:
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
如果OP的進程凍結(我們可以稱之爲凍結,因爲在啓動時讓進程閒置不應該花費很長時間),您會做什麼?我只是想知道,因爲我已經建議OP等待了一段時間,然後殺死它,如果它不成爲在該時間段空閒,但即使有一個無限循環等待空閒狀態這是不被重視(我昨天在源代碼中檢查過)。 – TLama 2012-07-13 09:02:13
的Windows的安裝標籤用於基於MSI的Windows安裝程序。不要濫用它。 – 2012-07-12 01:58:09
我的不好。學過的知識。 – mcbainpc 2012-07-13 00:57:44
我假設你正在執行'網絡啓動'等。不要這樣做,使用WinAPI服務控制功能。然後,您可以更好地控制您在放棄和決定如何從此恢復(例如顯示錯誤)之前等待服務響應的時間。 – Miral 2012-07-13 01:25:06