diff --git a/src/Febe.Desktop/MainWindow.cs b/src/Febe.Desktop/MainWindow.cs index cf395fd..8dfb6ab 100644 --- a/src/Febe.Desktop/MainWindow.cs +++ b/src/Febe.Desktop/MainWindow.cs @@ -1,6 +1,7 @@ using System.ComponentModel; using System.Windows; using System.Windows.Media; +using System.Windows.Threading; using Microsoft.Web.WebView2.Core; using Microsoft.Web.WebView2.Wpf; @@ -120,7 +121,7 @@ internal sealed class MainWindow : Window e.Cancel = true; if (uri.Scheme is "http" or "https") { - _ = _openOutside(uri); + OpenOutsideLater(uri); } } @@ -138,7 +139,13 @@ internal sealed class MainWindow : Window } else if (uri.Scheme is "http" or "https") { - _ = _openOutside(uri); + OpenOutsideLater(uri); } } + + /// + /// Opens in Alberto's browser once the handler of WebView2's event has returned: the shell + /// may run a message loop of its own, and WebView2 does not support re-entering its handlers (threading model). + /// + private void OpenOutsideLater(Uri uri) => Dispatcher.InvokeAsync(() => _openOutside(uri), DispatcherPriority.Background); }