mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
singleInstance Electron Manifest setting should handle command line arguments #611
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Delpire on GitHub (Dec 8, 2020).
Originally assigned to: @GregorBiswanger on GitHub.
Currently there are two ways of enforcing an app to be single instance.
"singleInstance": truein the electron manifest jsonThe first option seems to be the most reliable and robust. It works the fastest since it is being done in the javascript before the ASP .NET Core application launches (at least that is my understanding). However, one major problem is that you cannot handle the command line arguments to this second instance.
The alternative to this, is to set this to false and write the code to handle it ourselves, but this has several problems. Firstly, I can't get the callback to work, see #519 . Secondly, the second instance will always launch the splash screen, which is undesired if I have an instance running (and not a problem using the
singleInstancein the manifest).I really think both problems should be fixed, but I would be happy with one of the following two solutions.
Solution 1: Allow the javascript to take arguments and pass them to .NET. Then we can just check for the lock and handle the arguments.
Solution 2: Provide a new setting to the electron.manifest.json that will cause main.js to first check if it has the lock, and if it does not have the lock, don't display the Splashscreen, but continue to call the ASP .NET Core stuff so that we can handle the arguments.
I believe the only work around (assuming I can get the callback working or that gets fixed), is to handle showing the splash screen myself. That concerns me because I believe the app will seem more responsive at launch when the javascript launches the splash screen. My app seems to take a long time to load, and I am concerned that the splash screen will take a long time to show up if I write that code myself in .NET
@GregorBiswanger commented on GitHub (Jul 2, 2021):
Hi @Delpire, this feature is implemented for the next Electron.NET 13.5.1 release.
If the second instance is opened with arguments, the main application that has landed receives a focus. If you subscribe to this event, you can also request your new arguments.
As example: