Refactor theme change handler for safe async updates

Refactored OnThemeChanged in MainLayout.razor to use InvokeAsync for proper synchronization of UI updates and async logic, preventing threading issues. Also added a blank line after app.Run() in Program.cs (no functional impact).
This commit is contained in:
OlgunR
2026-05-11 13:36:44 +02:00
parent 1112fa215c
commit a6a17991bb
2 changed files with 7 additions and 6 deletions

View File

@@ -50,13 +50,14 @@
await ApplyDxDarkOverrideAsync();
}
private async void OnThemeChanged()
private void OnThemeChanged()
{
StateHasChanged();
if (_isInteractive)
InvokeAsync(async () =>
{
await ApplyDxDarkOverrideAsync();
}
StateHasChanged();
if (_isInteractive)
await ApplyDxDarkOverrideAsync();
});
}
private async Task ApplyDxDarkOverrideAsync()