diff --git a/CefSharp/CefSharp.h b/CefSharp/CefSharp.h index 6e5fe3b75..29c4ff88d 100644 --- a/CefSharp/CefSharp.h +++ b/CefSharp/CefSharp.h @@ -48,6 +48,14 @@ namespace CefSharp SetEvent(_event); } + static void ParentProcessExitHandler(Object^ sender, EventArgs^ e) + { + if (CEF::IsInitialized) + { + CEF::Shutdown(); + } + } + internal: static IDictionary^ GetBoundObjects() { @@ -97,6 +105,11 @@ namespace CefSharp { success = CefInitialize(*settings->_cefSettings, nullptr); _initialized = success; + + if (_initialized) + { + AppDomain::CurrentDomain->ProcessExit += gcnew EventHandler(ParentProcessExitHandler); + } } return success; }