Inno Setup: How to modify long running script so it will not freeze GUI?

后端 未结 2 1143
半阙折子戏
半阙折子戏 2020-12-01 20:33

I have an Inno Setup install that execute some time consuming \'AfterInstall\' action. And while this action is executed, install GUI is completely frozen (seems it\'s main

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 20:47

    There are two ways to improve the experience (they are different from an API point of view only, internally both do the same – they pump a Windows message queue):

    1. Use TOutputProgressWizardPage to present an operation progress. Its SetProgress method internally calls VCL TApplication.ProcessMessages, which pumps Windows message queue.

      Use CreateOutputProgressPage to create the page.

      Some examples:

      • Inno Setup Get progress from .NET Framework 4.5 (or higher) installer to update progress bar position
      • How to delay without freezing in Inno Setup
      • Inno Setup - Make Inno Setup Installer report its installation progress status to master installer
      • Inno setup: ExtractTemporaryFile causes wizard freeze
      • Inno Setup torrent download implementation
      • Inno Setup - How to add multiple arc files to decompress?
    2. Explicitly pump the Windows message queue by calling WinAPI DispatchMessage.

      For some examples, see AppProcessMessage function in:

      • My SQL server discovery on LAN by listening port (Inno Setup)
      • How to execute 7zip without blocking the InnoSetup UI?
      • and others

    In both cases, you have to add calls that trigger the message queue pumping. Usually within some loop that does the processing.

    In some cases, you won't be able to do that. For example, when you use a blocking call to an external application (e.g. using Exec or ShellExec) to do the processing. You can workaround that by scheduling a timer that will be regularly triggered, while the function is running.

    This approach is used by some examples linked above, namely:

    • Inno Setup - Make Inno Setup Installer report its installation progress status to master installer
    • Inno Setup torrent download implementation

提交回复
热议问题