Example #1
0
        internal static void Initialize()
        {
            if (initialized)
            {
                throw new CefException("ChromiumWebBrowser library already initialized.");
            }


            int retval = CfxRuntime.ExecuteProcess();

            if (retval >= 0)
            {
                Environment.Exit(retval);
            }


            app            = new CfxApp();
            processHandler = new CfxBrowserProcessHandler();

            app.GetBrowserProcessHandler      += (s, e) => e.SetReturnValue(processHandler);
            app.OnBeforeCommandLineProcessing += (s, e) => BrowserCore.RaiseOnBeforeCommandLineProcessing(e);
            app.OnRegisterCustomSchemes       += (s, e) => BrowserCore.RaiseOnRegisterCustomSchemes(e);

            var settings = new CfxSettings();

            settings.MultiThreadedMessageLoop = true;
            settings.NoSandbox = true;

            BrowserCore.RaiseOnBeforeCfxInitialize(settings, processHandler);

            if (!CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain))
            {
                throw new CefException("Failed to initialize CEF library.");
            }

            initialized = true;
        }