Shutdown with blazorserver app leaves process running #444

Closed
opened 2026-01-29 16:39:47 +00:00 by claunia · 3 comments
Owner

Originally created by @ghost on GitHub (Jan 27, 2020).

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)

Originally created by @ghost on GitHub (Jan 27, 2020). 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)](https://user-images.githubusercontent.com/19331584/73194379-08c55680-4124-11ea-86cd-d8599dfc2e4b.png)
claunia added the bug label 2026-01-29 16:39:47 +00:00
Author
Owner

@syedadeel2 commented on GitHub (Mar 2, 2020):

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

@syedadeel2 commented on GitHub (Mar 2, 2020): I had the same issue but fixed by changing "singleInstance": false to "singleInstance": true, in electron.manifest.json
Author
Owner

@MarkBQE commented on GitHub (May 25, 2020):

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

@MarkBQE commented on GitHub (May 25, 2020): 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](https://user-images.githubusercontent.com/23547957/82775899-f6bba200-9dfd-11ea-9352-837916491f1b.png)
Author
Owner

@MarkBQE commented on GitHub (May 25, 2020):

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;

                 

              };
@MarkBQE commented on GitHub (May 25, 2020): 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; };
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#444