Exemplo n.º 1
0
        public static int Main(string[] args)
        {
            Debug.WriteLine("BrowserSubprocess starting up with command line: " + String.Join("\n", args));

            SubProcess.EnableHighDPISupport();

            int result;
            var type            = args.GetArgumentValue(CefSharpArguments.SubProcessTypeArgument);
            var parentProcessId = int.Parse(args.GetArgumentValue(CefSharpArguments.HostProcessIdArgument));

            if (args.HasArgument(CefSharpArguments.ExitIfParentProcessClosed))
            {
                Task.Factory.StartNew(() => AwaitParentProcessExit(parentProcessId), TaskCreationOptions.LongRunning);
            }

            //Use our custom subProcess provides features like EvaluateJavascript
            if (type == "renderer")
            {
                var wcfEnabled = args.HasArgument(CefSharpArguments.WcfEnabledArgument);
                var subProcess = wcfEnabled ? new WcfEnabledSubProcess(parentProcessId, args) : new SubProcess(args);

                using (subProcess)
                {
                    result = subProcess.Run();
                }
            }
            else
            {
                result = SubProcess.ExecuteProcess();
            }

            Debug.WriteLine("BrowserSubprocess shutting down.");

            return(result);
        }
Exemplo n.º 2
0
        public static int Main(string[] args)
        {
            Debug.WriteLine("BrowserSubprocess starting up with command line: " + String.Join("\n", args));

            SubProcess.EnableHighDPISupport();

            int result;

            const string typePrefix   = "--type=";
            var          typeArgument = args.SingleOrDefault(arg => arg.StartsWith(typePrefix));
            var          type         = typeArgument.Substring(typePrefix.Length);

            //Use our custom subProcess provides features like EvaluateJavascript
            if (type == "renderer")
            {
                var wcfEnabled = args.HasArgument(CefSharpArguments.WcfEnabledArgument);
                var subProcess = wcfEnabled ? new WcfEnabledSubProcess(args) : new SubProcess(args);

                using (subProcess)
                {
                    result = subProcess.Run();
                }
            }
            else
            {
                result = SubProcess.ExecuteProcess();
            }

            Debug.WriteLine("BrowserSubprocess shutting down.");

            return(result);
        }
Exemplo n.º 3
0
        private static int Main(string[] args)
        {
            SubProcess.EnableHighDPISupport();

            string FindArg(string key)
            {
                return(Array.Find(args, arg => arg.StartsWith(key, StringComparison.OrdinalIgnoreCase)).Substring(key.Length));
            }

            const string typePrefix     = "--type=";
            const string parentIdPrefix = "--host-process-id=";

            if (!int.TryParse(FindArg(parentIdPrefix), out int parentId))
            {
                return(0);
            }

            Task.Factory.StartNew(() => KillWhenHung(parentId), TaskCreationOptions.LongRunning);

            if (FindArg(typePrefix) == "renderer")
            {
                using SubProcess subProcess = new SubProcess(null, args);
                return(subProcess.Run());
            }
            else
            {
                return(SubProcess.ExecuteProcess(args));
            }
        }
Exemplo n.º 4
0
        private static int Main(string[] args)
        {
            SubProcess.EnableHighDPISupport();

            const string typePrefix = "--type=";
            string       type       = Array.Find(args, arg => arg.StartsWith(typePrefix, StringComparison.OrdinalIgnoreCase)).Substring(typePrefix.Length);

            if (type == "renderer")
            {
                using (RendererProcess subProcess = new RendererProcess(args)){
                    return(subProcess.Run());
                }
            }
            else
            {
                return(SubProcess.ExecuteProcess());
            }
        }
Exemplo n.º 5
0
        public static int Main(string[] args)
        {
            Debug.WriteLine("BrowserSubprocess starting up with command line: " + String.Join("\n", args));

            SubProcess.EnableHighDPISupport();

            int result;
            var type = args.GetArgumentValue(CefSharpArguments.SubProcessTypeArgument);

            var parentProcessId = -1;

            // The Crashpad Handler doesn't have any HostProcessIdArgument, so we must not try to
            // parse it lest we want an ArgumentNullException.
            if (type != "crashpad-handler")
            {
                parentProcessId = int.Parse(args.GetArgumentValue(CefSharpArguments.HostProcessIdArgument));
                if (args.HasArgument(CefSharpArguments.ExitIfParentProcessClosed))
                {
                    Task.Factory.StartNew(() => AwaitParentProcessExit(parentProcessId), TaskCreationOptions.LongRunning);
                }
            }

            // Use our custom subProcess provides features like EvaluateJavascript
            if (type == "renderer")
            {
                //Add your own custom implementation of IRenderProcessHandler here
                IRenderProcessHandler handler = null;
                var wcfEnabled = args.HasArgument(CefSharpArguments.WcfEnabledArgument);
                var subProcess = wcfEnabled ? new WcfEnabledSubProcess(parentProcessId, handler, args) : new SubProcess(handler, args);

                using (subProcess)
                {
                    result = subProcess.Run();
                }
            }
            else
            {
                result = SubProcess.ExecuteProcess(args);
            }

            Debug.WriteLine("BrowserSubprocess shutting down.");

            return(result);
        }