您好,我想知道如何在 Inno Setup Pascal Script 中将工作(或命令)延迟指定时间。
内置的Sleep(const Milliseconds: LongInt)
睡觉时冻结所有工作。
我实现的以下功能也使WizardForm
无响应但不像内置的那样冻结Sleep()
功能。
procedure SleepEx(const MilliSeconds: LongInt);
begin
ShellExec('Open', 'Timeout.exe', '/T ' + IntToStr(MilliSeconds div 1000), '', SW_HIDE,
ewWaitUntilTerminated, ErrorCode);
end;
我也读过this,但无法想出如何在我的函数中使用它。
我想知道如何使用WaitForSingleObject
在这个SleepEx
功能。
在此先感谢您的帮助。
使用自定义进度页面(CreateOutputProgressPage功能):
procedure CurStepChanged(CurStep: TSetupStep);
var
ProgressPage: TOutputProgressWizardPage;
I, Step, Wait: Integer;
begin
if CurStep = ssPostInstall then
begin
// start your asynchronous process here
Wait := 5000;
Step := 100; // smaller the step is, more responsive the window will be
ProgressPage :=
CreateOutputProgressPage(
WizardForm.PageNameLabel.Caption, WizardForm.PageDescriptionLabel.Caption);
ProgressPage.SetText('Doing something...', '');
ProgressPage.SetProgress(0, Wait);
ProgressPage.Show;
try
// instead of a fixed-length loop,
// query your asynchronous process completion/state
for I := 0 to Wait div Step do
begin
// pumps a window message queue as a side effect,
// what prevents the freezing
ProgressPage.SetProgress(I * Step, Wait);
Sleep(Step);
end;
finally
ProgressPage.Hide;
ProgressPage.Free;
end;
end;
end;
这里的关键点是,SetProgress
调用泵窗口消息队列,什么可以防止冻结。
但实际上,您并不需要固定长度的循环,而是使用不确定的进度条并在循环中查询 DLL 的状态。
为此,请参阅Inno Setup:C# DLL 中用于长时间同步操作的字幕样式进度条.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)