Skip to content

Commit

Permalink
update TrayIcon.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacato committed Jun 25, 2024
1 parent a6f7e44 commit 44e97f8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Avalonia.Controls/TrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ static TrayIcon()
throw new InvalidOperationException("TrayIcon.Icons must be set on the Application.");
}
});

var app = Application.Current ?? throw new InvalidOperationException("Application not yet initialized.");

if (app.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime)

Application.ApplicationCurrentInitialized += (sender, args) =>
{
lifetime.Exit += Lifetime_Exit;
}
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime)
{
lifetime.Exit += Lifetime_Exit;
}
};

}

/// <summary>
Expand Down

0 comments on commit 44e97f8

Please sign in to comment.