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 AvaloniaAppHost(comm); service.Start(); Application.Run(); }
public void Start(string targetExe, string initialXaml, string sourceAssembly) { if (_proc != null) { _proc.Exited -= OnExited; try { _comm?.Dispose(); _proc.Kill(); } catch { } HandleExited(); State = "Restarting..."; } var msg = new InitMessage(Path.GetFullPath(targetExe), initialXaml, sourceAssembly); 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; }
public void UpdateXaml(string xaml, string sourceAssembly) { _comm?.SendMessage(new UpdateXamlMessage(xaml, sourceAssembly)); }
public void Start(string targetExe, string initialXaml, string sourceAssembly) { if (_proc != null) { _proc.Exited -= OnExited; try { _comm?.Dispose(); _proc.Kill(); } catch { } HandleExited(); State = "Restarting..."; } var msg = new InitMessage(Path.GetFullPath(targetExe), initialXaml, sourceAssembly); 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; }
public void UpdateXaml(string xaml) { _comm?.SendMessage(new UpdateXamlMessage(xaml)); }