protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); string cefPath = Path.Combine(Path.GetDirectoryName(GetProjectPath()), "cef"); bool externalMessagePump = e.Args.Contains("--external-message-pump"); var settings = new CefSettings(); settings.MultiThreadedMessageLoop = !externalMessagePump; settings.ExternalMessagePump = externalMessagePump; settings.NoSandbox = true; settings.WindowlessRenderingEnabled = true; settings.LocalesDirPath = Path.Combine(cefPath, "Resources", "locales"); settings.ResourcesDirPath = Path.Combine(cefPath, "Resources"); settings.LogSeverity = CefLogSeverity.Warning; settings.IgnoreCertificateErrors = true; settings.UncaughtExceptionStackSize = 8; app = new CefAppImpl(); app.ScheduleMessagePumpWorkCallback = OnScheduleMessagePumpWork; app.Initialize(Path.Combine(cefPath, "Release"), settings); if (externalMessagePump) { messagePump = new Timer(_ => Dispatcher.BeginInvoke(new Action(CefApi.DoMessageLoopWork)), null, messagePumpDelay, messagePumpDelay); } }
static void Main(string[] args) { //Application.SetHighDpiMode(HighDpiMode.SystemAware); //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); string cefPath = Path.Combine(Path.GetDirectoryName(GetProjectPath()), "cef"); bool externalMessagePump = args.Contains("--external-message-pump"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; var settings = new CefSettings(); settings.MultiThreadedMessageLoop = !externalMessagePump; settings.ExternalMessagePump = externalMessagePump; settings.NoSandbox = true; settings.WindowlessRenderingEnabled = true; settings.LocalesDirPath = Path.Combine(cefPath, "Resources", "locales"); settings.ResourcesDirPath = Path.Combine(cefPath, "Resources"); settings.LogSeverity = CefLogSeverity.Warning; settings.IgnoreCertificateErrors = true; settings.UncaughtExceptionStackSize = 8; var app = new CefAppImpl(); app.ScheduleMessagePumpWorkCallback = OnScheduleMessagePumpWork; try { app.BeforeInitialize += App_BeforeInitialize; app.Initialize(Path.Combine(cefPath, "Release"), settings); if (externalMessagePump) { messagePump = new System.Threading.Timer(_ => Application.RunOnUIThread(CefApi.DoMessageLoopWork), null, messagePumpDelay, messagePumpDelay); } mainForm = new MainForm(); //mainForm.UseSystemDecorations = true; Application.Run(mainForm); } finally { messagePump?.Dispose(); app.Shutdown(); app.Dispose(); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); string cefPath = Path.Combine(Path.GetDirectoryName(GetProjectPath()), "cef"); var settings = new CefSettings(); settings.MultiThreadedMessageLoop = true; settings.NoSandbox = true; settings.WindowlessRenderingEnabled = true; settings.LocalesDirPath = Path.Combine(cefPath, "Resources", "locales"); settings.ResourcesDirPath = Path.Combine(cefPath, "Resources"); settings.LogSeverity = CefLogSeverity.Warning; settings.IgnoreCertificateErrors = true; settings.UncaughtExceptionStackSize = 8; app = new CefAppImpl(); app.Initialize(Path.Combine(cefPath, "Release"), settings); }