示例#1
0
 static void HostedMain()
 {
     //Initialize sync context
     SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
     var comm = new CommChannel(Console.OpenStandardInput(), Console.OpenStandardOutput());
     Console.SetOut(new NullTextWriter());
     Console.SetError(new NullTextWriter());
     comm.Disposed += () => Process.GetCurrentProcess().Kill();
     comm.SendMessage(new StateMessage("Staying awhile and listening..."));
     var service = new PerspexAppHost(comm);
     service.Start();
     Application.Run();
 }
示例#2
0
        public void Start(string targetExe, string initialXaml)
        {
            if (_proc != null)
            {
                _proc.Exited -= OnExited;
                try
                {
                    _proc.Kill();
                }
                catch { }
                HandleExited();
                State = "Restarting...";
            }

            var msg = new InitMessage(Path.GetFullPath(targetExe), initialXaml);
            var exe = typeof(ProcessHost).Assembly.GetModules()[0].FullyQualifiedName;

            _proc = new Process()
            {
                StartInfo = new ProcessStartInfo(exe, "--hosted")
                {
                    UseShellExecute        = false,
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    CreateNoWindow         = true
                },
                EnableRaisingEvents = true
            };
            _proc.Exited += OnExited;
            try
            {
                _proc.Start();
                State            = "Launching designer process...";
                _comm            = new CommChannel(_proc.StandardOutput.BaseStream, _proc.StandardInput.BaseStream);
                _comm.OnMessage += OnMessage;
                _comm.Start();
                _comm.SendMessage(msg);
            }
            catch (Exception e)
            {
                State = e.ToString();
                HandleExited();
            }
            IsAlive = true;
        }
示例#3
0
        public void Start(string targetExe, string initialXaml)
        {
            if (_proc != null)
            {
                _proc.Exited -= OnExited;
                try
                {
                    _proc.Kill();
                }
                catch { }
                HandleExited();
                State = "Restarting...";
            }

            var msg = new InitMessage(Path.GetFullPath(targetExe), initialXaml);
            var exe = typeof (ProcessHost).Assembly.GetModules()[0].FullyQualifiedName;
            _proc = new Process()
            {
                StartInfo = new ProcessStartInfo(exe, "--hosted")
                {
                    UseShellExecute = false,
                    RedirectStandardInput = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true,
                    CreateNoWindow = true
                },
                EnableRaisingEvents = true
            };
            _proc.Exited += OnExited;
            try
            {
                _proc.Start();
                State = "Launching designer process...";
                _comm = new CommChannel(_proc.StandardOutput.BaseStream, _proc.StandardInput.BaseStream);
                _comm.OnMessage += OnMessage;
                _comm.Start();
                _comm.SendMessage(msg);
            }
            catch (Exception e)
            {
                State = e.ToString();
                HandleExited();
            }
            IsAlive = true;

        }
示例#4
0
 public PerspexAppHost(CommChannel channel)
 {
     _comm = channel;
     _appModel = new HostedAppModel(this);
 }
示例#5
0
 public PerspexAppHost(CommChannel channel)
 {
     _comm = channel;
 }