How to Display Electron progressbar modal in Electron.NET API ? #753

Closed
opened 2026-01-29 16:47:45 +00:00 by claunia · 1 comment
Owner

Originally created by @SheltonAlves on GitHub (Jan 6, 2022).

I have asp.net core application and I use ElectronNET.API.Electron.AutoUpdater to check for update at initial app start and I display electron Dialog when Update is available .
I need to show the download progress in electron dialog is it possible?
How do I display download progress in modal from startup.cs page?

Code :
ElectronNET.API.Electron.AutoUpdater.OnUpdateNotAvailable += async e => await OnUpdateNotAvailable(e);
ElectronNET.API.Electron.AutoUpdater.OnUpdateAvailable += async e => await OnUpdateAvailable(e);
ElectronNET.API.Electron.AutoUpdater.OnError += async e => await OnInstallUpdateFailed(e);

        Electron.AutoUpdater.OnDownloadProgress += (info) =>
        {
            var message1 = "Download speed: " + info.BytesPerSecond + "\n<br/>";
            var message2 = "Downloaded " + info.Percent + "%" + "\n<br/>";
            var message3 = $"({info.Transferred}/{info.Total})" + "\n<br/>";
            var message4 = "Progress: " + info.Progress + "\n<br/>";
            var information = message1 + message2 + message3 + message4;
            Console.WriteLine(information);
        };
        
         private async Task OnUpdateAvailable(UpdateInfo updateInfo)
    {
        var message = $"PRODUCT {updateInfo.Version} is available.";
        var result = await Electron.Dialog.ShowMessageBoxAsync(new MessageBoxOptions(message)
        {
            Title = "Updates",
            Type = MessageBoxType.info,
            NoLink = true,
            Buttons = new[]{"Update and restart application","Update Later"}
        });

        if (result.Response == 0)
        {
            await ElectronNET.API.Electron.AutoUpdater.DownloadUpdateAsync();
        }
        if (result.Response == 1)
        {
            await OpenElectronWindow();
        }
    }
Originally created by @SheltonAlves on GitHub (Jan 6, 2022). I have asp.net core application and I use ElectronNET.API.Electron.AutoUpdater to check for update at initial app start and I display electron Dialog when Update is available . I need to show the download progress in electron dialog is it possible? How do I display download progress in modal from startup.cs page? Code : ElectronNET.API.Electron.AutoUpdater.OnUpdateNotAvailable += async e => await OnUpdateNotAvailable(e); ElectronNET.API.Electron.AutoUpdater.OnUpdateAvailable += async e => await OnUpdateAvailable(e); ElectronNET.API.Electron.AutoUpdater.OnError += async e => await OnInstallUpdateFailed(e); Electron.AutoUpdater.OnDownloadProgress += (info) => { var message1 = "Download speed: " + info.BytesPerSecond + "\n<br/>"; var message2 = "Downloaded " + info.Percent + "%" + "\n<br/>"; var message3 = $"({info.Transferred}/{info.Total})" + "\n<br/>"; var message4 = "Progress: " + info.Progress + "\n<br/>"; var information = message1 + message2 + message3 + message4; Console.WriteLine(information); }; private async Task OnUpdateAvailable(UpdateInfo updateInfo) { var message = $"PRODUCT {updateInfo.Version} is available."; var result = await Electron.Dialog.ShowMessageBoxAsync(new MessageBoxOptions(message) { Title = "Updates", Type = MessageBoxType.info, NoLink = true, Buttons = new[]{"Update and restart application","Update Later"} }); if (result.Response == 0) { await ElectronNET.API.Electron.AutoUpdater.DownloadUpdateAsync(); } if (result.Response == 1) { await OpenElectronWindow(); } }
Author
Owner

@danatcofo commented on GitHub (Jan 6, 2022):

You will have to creat the page like a standard window and then send your messages to it like any other to show progress. None of this is out of the box unless there is something built into electron itself you can leverage. I don't think there is but I'm certainly not an electron expert.

@danatcofo commented on GitHub (Jan 6, 2022): You will have to creat the page like a standard window and then send your messages to it like any other to show progress. None of this is out of the box unless there is something built into electron itself you can leverage. I don't think there is but I'm certainly not an electron expert.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#753