public static void Main() { #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #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(); Application.Run(browser); }
private void TimerTick(object sender, EventArgs e) { //Reset the timer interval to maximum timer.Interval = MaxTimerDelay; //Execute DoMessageLoopWork on UI thread dispatcher.BeginInvoke((Action)(() => Cef.DoMessageLoopWork())); }
private void TimerTick(object sender, EventArgs e) { //Reset the timer interval to maximum timer.Interval = MaxTimerDelay; //Execute DoMessageLoopWork on UI thread factory.StartNew(() => Cef.DoMessageLoopWork()); }
protected override void OnScheduleMessagePumpWork(int delay) { //when delay <= 0 queue the Task up for execution on the UI thread. if (delay <= 0) { //Update the timer to execute almost immediately factory.StartNew(() => Cef.DoMessageLoopWork()); } }
protected override void OnScheduleMessagePumpWork(int delay) { //When delay <= 0 we'll execute Cef.DoMessageLoopWork immediately // if it's greater than we'll just let the Timer which fires 30 times per second // care of the call if (delay <= 0) { dispatcher.BeginInvoke((Action)(() => Cef.DoMessageLoopWork()), DispatcherPriority.Normal); } }
/// <summary> /// The run message loop. /// </summary> public static void RunMessageLoop() { while (User32Methods.GetMessage(out Message msg, IntPtr.Zero, 0, 0) != 0) { Cef.DoMessageLoopWork(); User32Methods.TranslateMessage(ref msg); User32Methods.DispatchMessage(ref msg); } }
/// <summary> /// The run message loop. /// </summary> public static void RunMessageLoop() { while (User32Methods.GetMessage(out Message msg, IntPtr.Zero, 0, 0) != 0) { if (ChromelyConfiguration.Instance.HostPlacement.Frameless) { Cef.DoMessageLoopWork(); } User32Methods.TranslateMessage(ref msg); User32Methods.DispatchMessage(ref msg); } }
protected override void OnScheduleMessagePumpWork(long delay) { //If the delay is greater than the Maximum then use ThirtyTimesPerSecond //instead - we do this to achieve a minimum number of FPS if (delay > ThirtyTimesPerSecond) { delay = ThirtyTimesPerSecond; } //when delay <= 0 queue the Task up for execution on the UI thread. if (delay <= 0) { //Update the timer to execute almost immediately factory.StartNew(() => Cef.DoMessageLoopWork()); } }
protected override void OnScheduleMessagePumpWork(long delay) { //If the delay is greater than the Maximum then use ThirtyTimesPerSecond //instead - we do this to achieve a minimum number of FPS if (delay > ThirtyTimesPerSecond) { delay = ThirtyTimesPerSecond; } //When delay <= 0 we'll execute Cef.DoMessageLoopWork immediately // if it's greater than we'll just let the Timer which fires 30 times per second // care of the call if (delay <= 0) { dispatcher.BeginInvoke((Action)(() => Cef.DoMessageLoopWork()), DispatcherPriority.Normal); } }
/// <summary> /// The run message loop. /// </summary> public static void RunMessageLoop() { while (User32Methods.GetMessage(out Message msg, IntPtr.Zero, 0, 0) != 0) { if (msg.Value == (uint)WM.CLOSE) { DetachKeyboardHook(); } if (ChromelyConfiguration.Instance.HostPlacement.KioskMode && msg.Value == (uint)WM.HOTKEY && msg.WParam == (IntPtr)1) { User32Methods.PostMessage(NativeWindow.NativeInstance.Handle, (uint)WM.CLOSE, IntPtr.Zero, IntPtr.Zero); } if (ChromelyConfiguration.Instance.HostPlacement.Frameless || ChromelyConfiguration.Instance.HostPlacement.KioskMode) { Cef.DoMessageLoopWork(); } User32Methods.TranslateMessage(ref msg); User32Methods.DispatchMessage(ref msg); } }
public override int RunCore() { Message msg; var quitMsg = (uint)WM.QUIT; bool isMultiThreadedLoopSet = m_hostConfig.GetBooleanValue(CefSettingKeys.MultiThreadedMessageLoop, true); bool isExternalPumpSet = m_hostConfig.GetBooleanValue(CefSettingKeys.ExternalMessagePump, false); if (!isMultiThreadedLoopSet && !isExternalPumpSet) { Cef.RunMessageLoop(); } else { while (true) { if (User32Helpers.PeekMessage(out msg, IntPtr.Zero, 0, 0, PeekMessageFlags.PM_REMOVE)) { if (msg.Value == quitMsg) { break; } User32Methods.TranslateMessage(ref msg); User32Methods.DispatchMessage(ref msg); } // Do your idle processing if (isExternalPumpSet) { Cef.DoMessageLoopWork(); } } } return(0); }
private void Timer_Tick(object sender, EventArgs e) { Cef.DoMessageLoopWork(); }
static void Main(string[] args) { var options = Options.Parse(args); if (options.Help) { MessageBox.Show(options.GetHelpText(), "CefGlue Client"); return; } var settings = new CefSettings(); settings.MultiThreadedMessageLoop = options.MultiThreadedMessageLoop; settings.CachePath = Path.GetDirectoryName(Application.ExecutablePath) + "/cache"; settings.LogFile = Path.GetDirectoryName(Application.ExecutablePath) + "/CEF.log"; settings.LogSeverity = CefLogSeverity.Verbose; settings.JavaScriptFlags = "--expose_gc"; #if DEBUG settings.ReleaseDCheckEnabled = true; #endif // settings.GraphicsImplementation = CefGraphicsImplementation.DesktopInProcess; var app = new App(); try { Cef.Initialize(settings, app); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #if DIAGNOSTICS Cef.Logger.SetAllTargets(false); // Cef.Logger.SetTarget(Diagnostics.LogTarget.ScriptableObject, true); // Cef.Logger.SetTarget(Diagnostics.LogTarget.CefWebBrowser, true); Cef.Logger.SetTarget(Diagnostics.LogTarget.CefLoadHandler, true); Cef.Logger.SetTarget(Diagnostics.LogTarget.Default, true); #endif var version = Application.ProductVersion; // TODO: make Cef.Version property Cef.RegisterExtension("clientExtension", @" var cefGlue = cefGlue || {}; Object.defineProperty(cefGlue, ""version"", { value: """ + version + @""", configurable: false }); cefGlue.getDocumentState = function() { cefGlue.client.log('Querying document state... (cefGlue.getDocumentState)'); return true; } if (!cefGlue.client) { cefGlue.client = { dump: function() { native function Dump(); return Dump.apply(this, arguments); }, returnVoid: function() { native function ReturnVoid(); ReturnVoid(); }, returnVoidAndDisposeThis: function() { native function ReturnVoidAndDisposeThis(); ReturnVoidAndDisposeThis(); }, returnUndefined: function() { native function ReturnUndefined(); return ReturnUndefined(); }, returnNull: function() { native function ReturnNull(); return ReturnNull(); }, returnBool: function() { native function ReturnBool(); return ReturnBool(); }, returnInt: function() { native function ReturnInt(); return ReturnInt(); }, returnDouble: function() { native function ReturnDouble(); return ReturnDouble(); }, returnDate: function() { native function ReturnDate(); return ReturnDate(); }, returnString: function() { native function ReturnString(); return ReturnString(); }, returnArray: function() { native function ReturnArray(); return ReturnArray(); }, returnObject: function() { native function ReturnObject(); return ReturnObject(); }, returnComplexArray: function() { native function ReturnComplexArray(); return ReturnComplexArray(); }, returnComplexObject: function() { native function ReturnComplexObject(); return ReturnComplexObject(); }, subtractIntImplicit: function(a, b) { native function SubtractIntImplicit(); return SubtractIntImplicit(a, b); }, subtractIntExplicit: function(a, b) { native function SubtractIntExplicit(); return SubtractIntExplicit(a, b); }, get privateWorkingSet() { native function get_PrivateWorkingSet(); return get_PrivateWorkingSet(); }, log: function(message) { native function Log(); return Log.apply(this, arguments); }, leakTestV8Func: function() { native function leakTestV8Func(); return leakTestV8Func(); }, }; }; ", new ClientV8Handler()); Cef.JSBinding.BindJSObject( "cefGlue.tests.scriptableObject.v8Extension", new TestScriptableObject(), JSBindingOptions.Extension | JSBindingOptions.Public ); // TODO: must be cefglue.scriptableObject.tests.jsBinding Cef.JSBinding.BindJSObject( "testScriptableObject", new TestScriptableObject() ); Cef.JSBinding.BindJSObject <IJSObject>( "iJSObject", new TestScriptableObject() ); var testObject1 = new CefGlue.Client.Examples.ScriptableObject.TestObject1(); Cef.JSBinding.BindJSObject(testObject1, JSBindingOptions.Extension | JSBindingOptions.Public); Cef.JSBinding.BindJSObject("myTestObject1", testObject1, JSBindingOptions.Extension | JSBindingOptions.Public); // res is registered in App.cs // Cef.RegisterCustomScheme("res", true, true, false); Cef.RegisterSchemeHandlerFactory("res", null, new ClientSchemeHandlerFactory()); // This is shows that handler works like zombie - when handler is used by native side only // it prevents to be collected by GC. CefTask.Post(CefThreadId.UI, () => { #if DIAGNOSTICS Cef.Logger.Trace(Diagnostics.LogTarget.Default, "Cef.CurrentlyOn(CefThreadId.UI)=[{0}]", Cef.CurrentlyOn(CefThreadId.UI)); #endif }); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); GC.WaitForPendingFinalizers(); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); GC.WaitForPendingFinalizers(); CefTask.Post(CefThreadId.IO, () => { #if DIAGNOSTICS Cef.Logger.Trace(Diagnostics.LogTarget.Default, "Cef.CurrentlyOn(CefThreadId.IO)=[{0}]", Cef.CurrentlyOn(CefThreadId.IO)); #endif }); CefTask.Post(CefThreadId.File, () => { #if DIAGNOSTICS Cef.Logger.Trace(Diagnostics.LogTarget.Default, "Cef.CurrentlyOn(CefThreadId.File)=[{0}]", Cef.CurrentlyOn(CefThreadId.File)); #endif }); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!Cef.CurrentSettings.MultiThreadedMessageLoop && !options.CefMessageLoop) { Application.Idle += (sender, e) => { Cef.DoMessageLoopWork(); }; } using (var mainForm = new MainForm()) { if (Cef.CurrentSettings.MultiThreadedMessageLoop || !options.CefMessageLoop) { Application.Run(mainForm); } else { mainForm.Show(); Cef.RunMessageLoop(); } /* * if (!cefMessageLoop) * { * for (var i = 0; i < 1000; i++) * { * Cef.DoMessageLoopWork(); * } * } */ } Cef.Shutdown(); }
protected virtual void OnScheduleMessagePumpWork(int delay) { //TODO: Schedule work on the UI thread - call Cef.DoMessageLoopWork Cef.DoMessageLoopWork(); }
private void TimerTick(object sender, EventArgs e) { //Basically execute Cef.DoMessageLoopWork 30 times per second, on the UI Thread dispatcher.BeginInvoke((Action)(() => Cef.DoMessageLoopWork()), DispatcherPriority.Render); }
public static int Main() { const bool simpleSubProcess = true; //AppDomain.CurrentDomain.AppendPrivatePath("CEF"); //增加DLL搜索路径 Cef.EnableHighDPISupport(); //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process. //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function if (simpleSubProcess) { var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } //#if DEBUG // if (!System.Diagnostics.Debugger.IsAttached) // { // MessageBox.Show("When running this Example outside of Visual Studio" + // "please make sure you compile in `Release` mode.", "Warning"); // } //#endif IMClient.Controls.StaticClass.XMPPCrack(); var settings = new CefSettings(); //settings.LocalesDirPath = Application.StartupPath + @"\CEF\locales"; //settings.BrowserSubprocessPath = "NetDLims.exe"; //settings.BrowserSubprocessPath = "CefSharp.BrowserSubprocess.exe"; settings.MultiThreadedMessageLoop = true; settings.AcceptLanguageList = "zh-CN"; settings.CachePath = "caches"; //加上特定版本的FLASH支持 settings.Locale = "zh-CN"; //settings.CefCommandLineArgs.Add("ppapi-flash-path", Application.StartupPath + "\\CEF\\PepperFlash\\pepflashplayer.dll"); //指定flash的版本,不使用系统安装的flash版本 //settings.CefCommandLineArgs.Add("ppapi-flash-version", "22.0.0.192"); bool ret = Cef.Initialize(settings, true, false); //var browser = new SimpleBrowserForm(); //Application.Run(browser); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Program.MainWindow = new BaseTemplateForm(); AppDomain.CurrentDomain.SetData("MainWindow", Program.MainWindow); Application.Run(Program.MainWindow); } else { //#if DEBUG // if (!System.Diagnostics.Debugger.IsAttached) // { // MessageBox.Show("When running this Example outside of Visual Studio" + // "please make sure you compile in `Release` mode.", "Warning"); // } //#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(); //Application.Run(browser); } return(0); }
private void TimerTick(object sender, EventArgs e) { //Basically execute Cef.DoMessageLoopWork 30 times per second Cef.DoMessageLoopWork(); }
private void TimerTick(object sender, EventArgs e) { //Basically execute Cef.DoMessageLoopWork 30 times per second //Execute DoMessageLoopWork on UI thread factory.StartNew(() => Cef.DoMessageLoopWork()); }
public static int Main(string[] args) { const bool simpleSubProcess = false; Cef.EnableHighDPISupport(); //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process. //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function if (simpleSubProcess) { var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #endif var settings = new CefSettings(); settings.BrowserSubprocessPath = "CefSharp.WinForms.Example.exe"; Cef.Initialize(settings); var browser = new SimpleBrowserForm(); Application.Run(browser); } else { #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #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(); Application.Run(browser); } return(0); }
public static void DoMessageLoopWork() { Cef.DoMessageLoopWork(); }