mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Guidance on calling Electon APIs from Blazor server code #907
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 @chrissmithptml on GitHub (Aug 1, 2023).
Maybe I'm just doing something wrong (which would not be the first time), but I just want to make sure.
So I have a Blazor Server app running in Electron.NET. All Blazor stuff is fine, as are all standard javascript calls.
If I wire up calls to the Electron.NET API behind the scenes (say setting up the electron menus in my Program.cs), this all works fine.
However, when I try to call Electon APIs via a Blazor button on the server, my app not only DOESN'T do the expected Electron action, but it ends up freezing my app.
My call is pretty simple, but maybe this is just not possible / there's something else I must do to make this work
Should this work just fine? Is there something else I need to do / some other way I need to wire this up in a Blazor Server app? Just trying to get some confirmation.
App Details
Blazor app type: Blazor server
Electon.NET Version: latest
.NET Version: 6.0x
@chrissmithptml commented on GitHub (Aug 16, 2023):
Worked it out, in case anyone else bumps up against this kind of thing.
My button method was a void, and my call to Electron used a
.Wait(). That and.Resultappear to be big ol' no-nos. They do NOT work. You have to ensure the Electron Shell calls are full on await async calls or they won't work as expected.