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

Open
opened 2026-01-29 16:47:42 +00:00 by claunia · 0 comments
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(); } }
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#750