Electron.net: Shutdown with blazorserver app leaves process running

Created on 27 Jan 2020  Â·  3Comments  Â·  Source: ElectronNET/Electron.NET

Electron.NET Tools (7.30.2+022221307cd0119dadeefcfe35ef45242f870779)
.NET Core SDK (reflecting any global.json):
Version: 3.1.101
Commit: b377529961
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64

node v12.11.1

Quitting the app leaves the process running.

  • Open empty folder ShutdownBlazorElectronNet in VSCode
  • Open terminal
  • % dotnet new blazorserver --no-https
  • % dotnet add package ElectronNET.API
  • % electronize init
  • % dotnet build

In Program.cs

    public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder
                        .UseStartup<Startup>()
                        .UseElectron(args);
                });

In Startup.cs

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
        …
        …
        Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());
    }
  • % dotnet build
  • % electronize start

App opens in Electron window, look at all three pages then Electron>Quit Electron or CMD+Q
In the Activity Monitor app, search for shut and the ShutdownBlazorElectronNet process is still present and active.
After three starts:

Activity Monitor (My Processes)

bug

All 3 comments

I had the same issue but fixed by changing "singleInstance": false to "singleInstance": true, in electron.manifest.json

This is still an issue on Mac, I am running Electron Net with Blazor server, changed the Single Instance to true as per Syed Adeel2 has no affect
image

Ok Fixed it. In the startup of Blazor server app please add the following code. what makes the .net process go away is Environment.Exit(0)

Electron.App.WindowAllClosed += () =>
{
Electron.App.Quit();
};

            browserWindow.OnClosed += () =>
              {
                  Electron.App.Exit(0);
                  Environment.Exit(0);
                   Electron.App.Quit();
                  browserWindow = null;



              };
Was this page helpful?
0 / 5 - 0 ratings