Skip to content

Commit 86b5c54

Browse files
committed
Add try/catch around _browserProcessServiceHost->Open call - seems that occasionally there's a timing issue
See #862, #804 and #1494
1 parent 4efa3ed commit 86b5c54

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

CefSharp.Core/ManagedCefBrowserAdapter.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,16 @@ void ManagedCefBrowserAdapter::OnAfterBrowserCreated(int browserId)
5555
_browserProcessServiceHost = gcnew BrowserProcessServiceHost(_javaScriptObjectRepository, Process::GetCurrentProcess()->Id, this);
5656
//NOTE: Attempt to solve timing issue where browser is opened and rapidly disposed. In some cases a call to Open throws
5757
// an exception about the process already being closed. Two relevant issues are #862 and #804.
58-
// Considering adding an IsDisposed check and also may have to revert to a try catch block
5958
if (_browserProcessServiceHost->State == CommunicationState::Created)
6059
{
61-
_browserProcessServiceHost->Open();
60+
try
61+
{
62+
_browserProcessServiceHost->Open();
63+
}
64+
catch (Exception^)
65+
{
66+
//Ignore exception as it's likely cause when the browser is closing
67+
}
6268
}
6369
}
6470

0 commit comments

Comments
 (0)