kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

How to do useful work while waiting for updater.exe

Sat Apr 01, 2023 6:57 pm

I have this code about 25 lines after the start of my Windows Forms app to automatically upgrade users if they want to upgrade. Checking for upgrades on a local disk takes about 350 ms of time at the front of the application boot cycle. Naturally, the 350 ms will expand to multiple seconds when upgrades are moved to a web server.

I would like to use some kind of async technique to get useful work done while waiting (let's say 5 seconds) for the AI updater.exe to check for updates on the web. But I cannot use C# async/await directly because my 'static int Main' program cannot be made async (else the thread would return and exit after seeing the first await on the updater.exe call).

What is the best way for my app thread to continue to do useful work while AI updater.exe is checking for upgrades (that mostly won't be there in 99% of the cases)? My thread can get a LOT done in 5 seconds. I see the /justcheck option that will return a 0 if upgrades are available. Maybe that will work for me. If nothing else, I can delay the upgrader.exe call like you do in your example.

Do you have a recommendation for doing anything async to make use of the time while the updater is checking? (Even if the updater returns a code saying there are upgrades, I don't want to wait for it to do the update). Thank you.

Code: Select all

if (! AiInstallerUpdater.UpdaterCheckForUpdatesOnAppBoot()) {
      var msg = @"Web automatic upgrade failed.";
      MessageBox.Show(msg);
      return 1;
}

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: How to do useful work while waiting for updater.exe

Tue Apr 04, 2023 3:36 pm

Hello,

I'm afraid my C# knowledge is quite limited and therefore I can not really offer an input here.

Thank you for your understanding!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”