Waiting for the Updater.exe to finish from the code (C#) - Advanced Installer Community
prasadus92
Posts: 58
Joined: Wed Feb 25, 2015 8:10 am

Waiting for the Updater.exe to finish from the code (C#)

Hi,

In my code, I am waiting for the Updater.exe to finish and do some custom tasks after it completes successfully (using Process.WaitForExit()). But the Updater.exe downloads the binary and creates another process (Installer) and wait till it finishes and will end once the installer ends. For me, as I am using Process.WaitForExit(), I am getting the process exit code (0) from Updater.exe once it completes the download of binary (before actually the installation happens). I need to wait till both these processes complete their job and I need to catch the error codes as well. How can I implement this?

Thanks in advance.
Prasad
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Waiting for the Updater.exe to finish from the code (C#)

Hello Prasad,

Please take a look on our "Wait for Updater" article and let us know if this is useful for you.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prasadus92
Posts: 58
Joined: Wed Feb 25, 2015 8:10 am

Re: Waiting for the Updater.exe to finish from the code (C#)

Hi Daniel,

Many thanks for your reply.

The link you provided is helpful to me. Whether there is C# version of this? That would be more ideal to deal with.

Thanks
Prasad
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Waiting for the Updater.exe to finish from the code (C#)

Hello Prasad,

You're always welcome.

I'm afraid we don't have a C# version of the above article. I've added this on our improvements list and maybe it will be available in a future version of Advanced Installer. Thank you for your suggestion.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prasadus92
Posts: 58
Joined: Wed Feb 25, 2015 8:10 am

Re: Waiting for the Updater.exe to finish from the code (C#)

Hi Daniel,

Thanks for the reply.

Also, I noticed that, if I run Updater.exe in a different process and in my code if I wait for it to finish using C# Process.WaitForExit (or check Process.HasExited), I am getting wrong outcomes.

The Process.HasExited becomes true even if the Updater.exe has not exited. Further, the Updater.exe downloads the binary from the URL mentioned in the Updates.txt and will fork a different process to take care of installation (running downloaded binary installer). I need to make sure that both these processes complete and then I can run my code further. Any help on this? I am aware that you have indicated there is C# version of that article you indicated.

Also please let me know if I need to create a separate thread on this.

Thanks in advance.
Prasad
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Waiting for the Updater.exe to finish from the code (C#)

Hello Prasad,

First of all I apologize for my delayed reply. We had a few days off here due to the Orthodox Easter holidays and we are a bit rushed this week.

Indeed, this is the normal behavior of our Updater tool. When launched it search for updates and if found, after downloading them it exits and just before exiting it copies itself in a temp location and starts a child process which will run the temp Updater which further install the updates. This procedure is required so that the installed Updater tool can be upgraded by the updates installation.
I am aware that you have indicated there is C# version of that article you indicated.
At this moment I'm afraid we don't have a C# version of the above article. I apologize for the inconvenience. We'll try to create one in a future version of Advanced Installer. Thank you for your understanding.

Until then, you can try to search for a C# way to programmatically wait for the child process of the Updater tool. Maybe the "Wait for all child processes of a ran process to finish C#" thread could be useful for you.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prasadus92
Posts: 58
Joined: Wed Feb 25, 2015 8:10 am

Re: Waiting for the Updater.exe to finish from the code (C#)

Hi Daniel,

Many thanks for the info.

I spent few days on this and I was able to wait for Updater.exe from my code. But later I ended up with some UI issues as I do the update by keeping my main application running.

So right now I am just showing a progress bar (indefinite) and running the updater in the background (without UI).

Also, the UI of the updater was not so good. Further, I already mentioned it in the feature requests and got reply as well.

Thanks again for your help.

Prasad

Return to “Common Problems”