mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
Add Cef.DoMessageLoopWork example to WinForms.Example project
This commit is contained in:
@@ -27,7 +27,7 @@ namespace CefSharp.Example
|
||||
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 @@ namespace CefSharp.Example
|
||||
//Possibly useful when experiencing blury fonts.
|
||||
//settings.CefCommandLineArgs.Add("disable-direct-write", "1");
|
||||
|
||||
settings.MultiThreadedMessageLoop = multiThreadedMessageLoop;
|
||||
|
||||
// Off Screen rendering (WPF/Offscreen)
|
||||
if(osr)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace CefSharp.OffScreen.Example
|
||||
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
|
||||
|
||||
@@ -22,7 +22,20 @@ namespace CefSharp.WinForms.Example
|
||||
}
|
||||
#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();
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace CefSharp.Wpf.Example
|
||||
}
|
||||
#endif
|
||||
|
||||
CefExample.Init(true);
|
||||
CefExample.Init(true, multiThreadedMessageLoop: true);
|
||||
|
||||
base.OnStartup(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user