diff --git a/CefSharp.Example/CefExample.cs b/CefSharp.Example/CefExample.cs index 5cc6f14815..350aa98c0f 100644 --- a/CefSharp.Example/CefExample.cs +++ b/CefSharp.Example/CefExample.cs @@ -27,7 +27,7 @@ public static class CefExample private static readonly bool DebuggingSubProcess = Debugger.IsAttached; private static string PluginInformation = ""; - public static void Init(bool osr) + public static void Init(bool osr, bool multiThreadedMessageLoop) { // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys // Environment.SetEnvironmentVariable("GOOGLE_API_KEY", ""); @@ -73,6 +73,8 @@ public static void Init(bool osr) //Possibly useful when experiencing blury fonts. //settings.CefCommandLineArgs.Add("disable-direct-write", "1"); + settings.MultiThreadedMessageLoop = multiThreadedMessageLoop; + // Off Screen rendering (WPF/Offscreen) if(osr) { diff --git a/CefSharp.OffScreen.Example/Program.cs b/CefSharp.OffScreen.Example/Program.cs index 96c90bf2af..ab03cfac96 100644 --- a/CefSharp.OffScreen.Example/Program.cs +++ b/CefSharp.OffScreen.Example/Program.cs @@ -22,7 +22,7 @@ public static void Main(string[] args) Console.WriteLine(); // You need to replace this with your own call to Cef.Initialize(); - CefExample.Init(true); + CefExample.Init(true, multiThreadedMessageLoop:true); MainAsync("cachePath1", 1.0); //Demo showing Zoom Level of 3.0 diff --git a/CefSharp.WinForms.Example/Program.cs b/CefSharp.WinForms.Example/Program.cs index afe5d85ce1..d9e1cebc14 100644 --- a/CefSharp.WinForms.Example/Program.cs +++ b/CefSharp.WinForms.Example/Program.cs @@ -22,7 +22,20 @@ public static void Main() } #endif - CefExample.Init(false); + const bool multiThreadedMessageLoop = true; + CefExample.Init(false, multiThreadedMessageLoop: multiThreadedMessageLoop); + + if(multiThreadedMessageLoop == false) + { + //http://magpcss.org/ceforum/apidocs3/projects/%28default%29/%28_globals%29.html#CefDoMessageLoopWork%28%29 + //Perform a single iteration of CEF message loop processing. + //This function is used to integrate the CEF message loop into an existing application message loop. + //Care must be taken to balance performance against excessive CPU usage. + //This function should only be called on the main application thread and only if CefInitialize() is called with a CefSettings.multi_threaded_message_loop value of false. + //This function will not block. + + Application.Idle += (s, e) => Cef.DoMessageLoopWork(); + } var browser = new BrowserForm(); //var browser = new SimpleBrowserForm(); diff --git a/CefSharp.Wpf.Example/App.xaml.cs b/CefSharp.Wpf.Example/App.xaml.cs index 906c05334f..0c393ac4ec 100644 --- a/CefSharp.Wpf.Example/App.xaml.cs +++ b/CefSharp.Wpf.Example/App.xaml.cs @@ -19,7 +19,7 @@ protected override void OnStartup(StartupEventArgs e) } #endif - CefExample.Init(true); + CefExample.Init(true, multiThreadedMessageLoop: true); base.OnStartup(e); }