Browse Source

Avoid ObjectDisposedException when host got disposed (#5003)

pull/5021/head
campersau 7 months ago
committed by GitHub
parent
commit
4757ee6f6c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      CefSharp/Internals/Partial/ChromiumWebBrowser.Partial.cs

16
CefSharp/Internals/Partial/ChromiumWebBrowser.Partial.cs

@ -449,11 +449,21 @@ namespace CefSharp.WinForms
initialLoadAction = null;
var host = browser?.GetHost();
int statusCode = 0;
var navEntry = host?.GetVisibleNavigationEntry();
try
{
var host = browser?.GetHost();
var navEntry = host?.GetVisibleNavigationEntry();
int statusCode = navEntry?.HttpStatusCode ?? -1;
statusCode = navEntry?.HttpStatusCode ?? -1;
}
catch (ObjectDisposedException)
{
// The host might got disposed
// https://github.com/cefsharp/CefSharp/issues/5002
}
//By default 0 is some sort of error, we map that to -1
//so that it's clearer that something failed.

Loading…
Cancel
Save