From b107d72c4383105aab4de491e7248175a372fc82 Mon Sep 17 00:00:00 2001 From: rastating Date: Wed, 23 Oct 2013 16:21:21 +0100 Subject: [PATCH] Fixed process not exiting in Windows XP Added a handler assignment on the first call to CefSharp::Initialize which will ensure CEF is shutdown properly should the calling program not manually call the shutdown method before the process exits. This bug only seems to affect Windows XP, however I have tested on both Windows XP and Windows 7 and with this change neither have any ghost processes left over after the program calling CefSharp exits. This commit fixes #80 --- CefSharp/CefSharp.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; }