Skip to content

Commit

Permalink
Merge pull request #2258 from cwensley/curtis/webview2-check-disposed
Browse files Browse the repository at this point in the history
Wpf: Check if WebView is disposed or not before sending events asynchronously
  • Loading branch information
cwensley authored Jul 15, 2022
2 parents 7f1eb2f + 10f0bff commit 79e2c5c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Eto.Wpf/Forms/Controls/WebView2Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ void Control_CoreWebView2Ready(object sender, CoreWebView2InitializationComplete

private void RunDelayedActions()
{
if (Widget.IsDisposed)
return;

Control.CoreWebView2.DocumentTitleChanged += CoreWebView2_DocumentTitleChanged;
Control.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
webView2Ready = true;
Expand Down Expand Up @@ -583,7 +586,11 @@ private void Control_NavigationStarting(object sender, CoreWebView2NavigationSta
private void Control_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
{
var args = new WebViewLoadedEventArgs(Control.Source);
Application.Instance.AsyncInvoke(() => Callback.OnDocumentLoaded(Widget, args));
Application.Instance.AsyncInvoke(() => {
if (Widget.IsDisposed)
return;
Callback.OnDocumentLoaded(Widget, args);
});
}

public Uri Url
Expand Down

0 comments on commit 79e2c5c

Please sign in to comment.