public static bool LoadAndInitCef3(string[] args) { initEssential = new MyCef3InitEssential(args); if (!initEssential.Init()) { return(false); } initEssential.SetupPreRun(); return(true); }
static void Main(string[] args) { //this is designed for cef UI process. //this process starts before any subprocess. //so before load anything we should check // if essential libs are available //------------------------------------------ LibFolderManager.CheckNativeLibs(); //------------------------------------------ //1. load cef before OLE init (eg init winform) *** //see more detail ... MyCef3InitEssential if (!MyCef3InitEssential.LoadAndInitCef3(args)) { return; } //------------------------------------------ //1. if this is main UI process //the code go here, and we just start //winform app as usual //2. if this is other process //mean this process is finish and will terminate soon. //so we do noting, just exit! //(***please note that //*** we call ShutDownCef3 only in main thread ***) if (!MyCef3InitEssential.IsInMainProcess) { MyCef3InitEssential.ClearRemainingCefMsg(); return; } //------------------------------------------ ///////////////////////////////////////////// //this code is run only in main process //------------------------------------------ MyCef3WinForms myCef3WinForm = new MyCef3WinForms(); myCef3WinForm.SetAsCurrentImpl(); WinFormCefMsgLoopPump.Start(); //------------------------------------------ Form1 f1 = new Form1(); ApplicationContext appContext = new ApplicationContext(f1); Application.Run(appContext); ///////////////////////////////////////////// MyCef3InitEssential.ClearRemainingCefMsg(); MyCef3InitEssential.ShutDownCef3(); //(***please note that //*** we call ShutDownCef3 only in main thread ***) }
public static void Start() { MyCef3InitEssential.CefDoMessageLoopWork(); if (tinyForm == null) { tinyForm = new Form(); tinyForm.Size = new System.Drawing.Size(10, 10); tinyForm.Visible = false; } //force it create handle**** tinyFormHandle = tinyForm.Handle; //Cef3's message pump *** //--------------------------- //this is CefMsgLoopPump implementation //it should not too fast or too slow to call bool appIsIdel = true; bool looping1 = false; loopTimer.Interval = 30;//30ms loopTimer.Tick += (s, e) => { if (appIsIdel) { looping1 = true; appIsIdel = false; for (int i = 10; i >= 0; --i) { MyCef3InitEssential.CefDoMessageLoopWork(); } looping1 = false; } }; Application.Idle += (s, e) => { if (!looping1) { appIsIdel = true; } }; loopTimer.Enabled = true; }
static void Main(string[] args) { //1. load cef before OLE init (eg init winform) *** //see more detail ... MyCef3InitEssential if (!MyCef3InitEssential.LoadAndInitCef3(args)) { return; } //------------------------------------------ //1. if this is main UI process //the code go here, and we just start //winform app as usual //2. if this is other process //mean this process is finish and will terminate soon. //so we do noting, just exit! //(***please note that //*** we call ShutDownCef3 only in main thread ***) if (!MyCef3InitEssential.IsInMainProcess) { MyCef3InitEssential.ClearRemainingCefMsg(); return; } //------------------------------------------ ///////////////////////////////////////////// //this code is run only in main process //------------------------------------------ Form1 f1 = new Form1(); ApplicationContext appContext = new ApplicationContext(f1); Application.Run(appContext); ///////////////////////////////////////////// MyCef3InitEssential.ClearRemainingCefMsg(); MyCef3InitEssential.ShutDownCef3(); //(***please note that //*** we call ShutDownCef3 only in main thread ***) }