mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-21 22:45:20 +00:00
implement lazy App.Ready event
This commit is contained in:
@@ -356,7 +356,24 @@ namespace ElectronNET.API
|
||||
/// <summary>
|
||||
/// Emitted when the application has finished basic startup.
|
||||
/// </summary>
|
||||
public event Action Ready;
|
||||
public event Action Ready
|
||||
{
|
||||
add
|
||||
{
|
||||
if(IsReady)
|
||||
{
|
||||
value();
|
||||
}
|
||||
|
||||
_ready += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_ready -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private event Action _ready;
|
||||
|
||||
/// <summary>
|
||||
/// Application host fully started.
|
||||
@@ -370,7 +387,7 @@ namespace ElectronNET.API
|
||||
|
||||
if(value)
|
||||
{
|
||||
Ready?.Invoke();
|
||||
_ready?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,7 @@ namespace ElectronNET.WebApp.Controllers
|
||||
{
|
||||
if (HybridSupport.IsElectronActive)
|
||||
{
|
||||
if(Electron.App.IsReady)
|
||||
{
|
||||
CreateContextMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
Electron.App.Ready += () => CreateContextMenu();
|
||||
}
|
||||
Electron.App.Ready += () => CreateContextMenu();
|
||||
|
||||
var menu = new MenuItem[] {
|
||||
new MenuItem { Label = "Edit", Submenu = new MenuItem[] {
|
||||
|
||||
Reference in New Issue
Block a user