Exemplo n.º 1
0
        private static int Main(string[] args)
        {
            try
            {
                CefRuntime.Load();
            }
            catch (DllNotFoundException ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return 1;
            }
            catch (CefRuntimeException ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return 2;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return 3;
            }

            var mainArgs = new CefMainArgs(args);
            var cefApp = new SampleCefApp();

            var exitCode = CefRuntime.ExecuteProcess(mainArgs, cefApp);
            if (exitCode != -1) { return exitCode; }

            var cefSettings = new CefSettings
            {
                // BrowserSubprocessPath = browserSubprocessPath,
                SingleProcess = false,
                WindowlessRenderingEnabled = true,
                MultiThreadedMessageLoop = true,
                LogSeverity = CefLogSeverity.Verbose,
                LogFile = "cef.log",
            };

            try
            {
                CefRuntime.Initialize(mainArgs, cefSettings, cefApp);
            }
            catch (CefRuntimeException ex)
            {
                MessageBox.Show(ex.ToString(), "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return 4;
            }


            var app = new Xilium.CefGlue.Samples.WpfOsr.App();
            app.InitializeComponent();
            app.Run();

            // shutdown CEF
            CefRuntime.Shutdown();

            return 0;
        }
Exemplo n.º 2
0
        private static int Main(string[] args)
        {
            try
            {
                CefRuntime.Load();
            }
            catch (DllNotFoundException ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return(1);
            }
            catch (CefRuntimeException ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return(2);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return(3);
            }

            var mainArgs = new CefMainArgs(args);
            var cefApp   = new SampleCefApp();

            var exitCode = CefRuntime.ExecuteProcess(mainArgs, cefApp, IntPtr.Zero);

            if (exitCode != -1)
            {
                return(exitCode);
            }

            var cefSettings = new CefSettings
            {
                // BrowserSubprocessPath = browserSubprocessPath,
                SingleProcess = false,
                WindowlessRenderingEnabled = true,
                MultiThreadedMessageLoop   = true,
                LogSeverity = CefLogSeverity.Verbose,
                LogFile     = "cef.log",
            };

            try
            {
                CefRuntime.Initialize(mainArgs, cefSettings, cefApp, IntPtr.Zero);
            }
            catch (CefRuntimeException ex)
            {
                MessageBox.Show(ex.ToString(), "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return(4);
            }


            var app = new Xilium.CefGlue.Samples.WpfOsr.App();

            app.InitializeComponent();
            app.Run();

            // shutdown CEF
            CefRuntime.Shutdown();

            return(0);
        }