11using System ;
22using System . Diagnostics ;
33using System . IO ;
4+ using System . Threading . Tasks ;
45using CefSharp . Internals ;
56
67namespace CefSharp . OutOfProcess . BrowserProcess
@@ -11,7 +12,7 @@ public static int Main(string[] args)
1112 {
1213 Cef . EnableHighDPISupport ( ) ;
1314
14- // Debugger.Launch();
15+ Debugger . Launch ( ) ;
1516
1617 var parentProcessId = int . Parse ( CommandLineArgsParser . GetArgumentValue ( args , "--parentProcessId" ) ) ;
1718 var hostHwnd = int . Parse ( CommandLineArgsParser . GetArgumentValue ( args , "--hostHwnd" ) ) ;
@@ -21,22 +22,29 @@ public static int Main(string[] args)
2122 var settings = new CefSettings ( )
2223 {
2324 //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
24- CachePath = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , "CefSharp\\ OutOfProcessCache" )
25+ CachePath = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , "CefSharp\\ OutOfProcessCache" ) ,
26+ MultiThreadedMessageLoop = false
2527 } ;
2628
29+ var browserProcessHandler = new BrowserProcessHandler ( parentProcessId , new IntPtr ( hostHwnd ) ) ;
30+
2731 Cef . EnableWaitForBrowsersToClose ( ) ;
2832
29- Cef . Initialize ( settings ) ;
33+ Cef . Initialize ( settings , performDependencyCheck : true , browserProcessHandler : browserProcessHandler ) ;
3034
31- var browser = new ChromiumWebBrowser ( "https://github.com" ) ;
35+ Task . Run ( ( ) =>
36+ {
37+ parentProcess . WaitForExit ( ) ;
3238
33- var windowInfo = new WindowInfo ( ) ;
34- windowInfo . WindowName = "CefSharpBrowserProcess" ;
35- windowInfo . SetAsChild ( new IntPtr ( hostHwnd ) ) ;
39+ CefThread . ExecuteOnUiThread ( ( ) =>
40+ {
41+ Cef . QuitMessageLoop ( ) ;
3642
37- browser . CreateBrowser ( windowInfo ) ;
43+ return true ;
44+ } ) ;
45+ } ) ;
3846
39- parentProcess . WaitForExit ( ) ;
47+ Cef . RunMessageLoop ( ) ;
4048
4149 Cef . WaitForBrowsersToClose ( ) ;
4250
0 commit comments