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; Application.ThreadException += Application_ThreadException; 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; app.CefProcessMessageReceived += ScriptableObjectTests.HandleScriptableObjectTestMessage; try { UIContext = new WindowsFormsSynchronizationContext(); SynchronizationContext.SetSynchronizationContext(UIContext); app.Initialize(Path.Combine(cefPath, "Release"), settings); if (externalMessagePump) { messagePump = new System.Threading.Timer(_ => UIContext.Post(_ => CefApi.DoMessageLoopWork(), null), null, messagePumpDelay, messagePumpDelay); } Application.Run(new MainForm()); using (var ev = new ManualResetEvent(false)) { app.SignalForShutdown(() => ev.Set()); ev.WaitOne(); } } finally { messagePump?.Dispose(); app.Shutdown(); app.Dispose(); } }
static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string cefPath = Path.Combine(Path.GetDirectoryName(GetProjectPath()), "cef"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ThreadException += Application_ThreadException; 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; var app = new CefAppImpl(); app.CefProcessMessageReceived += ScriptableObjectTests.HandleScriptableObjectTestMessage; try { app.Initialize(Path.Combine(cefPath, "Release"), settings); Application.Run(new MainForm()); } finally { app.Shutdown(); app.Dispose(); } }