Experimental implementation of IBrowserProcessHandler.OnScheduleMessagePumpWork

NOT READY FOR PRODUCTION USE
This commit is contained in:
amaitland
2016-09-01 16:51:20 +10:00
parent e7a5c0c3dd
commit 9fbde82ef0
7 changed files with 117 additions and 17 deletions
+21 -13
View File
@@ -3,8 +3,12 @@
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp.Example;
using CefSharp.Example.Handlers;
using CefSharp.WinForms.Example.Handlers;
using CefSharp.WinForms.Example.Minimal;
namespace CefSharp.WinForms.Example
@@ -56,23 +60,27 @@ namespace CefSharp.WinForms.Example
#endif
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();
//var browser = new TabulationDemoForm();
IBrowserProcessHandler browserProcessHandler;
if(multiThreadedMessageLoop)
{
browserProcessHandler = new BrowserProcessHandler();
}
else
{
//Get the current taskScheduler (must be called after the form is created)
var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
browserProcessHandler = new WinFormsBrowserProcessHandler(scheduler);
}
CefExample.Init(osr: false, multiThreadedMessageLoop: multiThreadedMessageLoop, browserProcessHandler: browserProcessHandler);
Application.Run(browser);
}