Skip to content

Commit

Permalink
Add Cef.DoMessageLoopWork example to WinForms.Example project
Browse files Browse the repository at this point in the history
  • Loading branch information
amaitland committed Oct 21, 2015
1 parent 221ec0d commit fe11f2e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CefSharp.Example/CefExample.cs
Expand Up @@ -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", "");
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion CefSharp.OffScreen.Example/Program.cs
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion CefSharp.WinForms.Example/Program.cs
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion CefSharp.Wpf.Example/App.xaml.cs
Expand Up @@ -19,7 +19,7 @@ protected override void OnStartup(StartupEventArgs e)
}
#endif

CefExample.Init(true);
CefExample.Init(true, multiThreadedMessageLoop: true);

base.OnStartup(e);
}
Expand Down

0 comments on commit fe11f2e

Please sign in to comment.