public InProcessHost(ClientStartInfo startInfo) { _startInfo = startInfo; _thread = new Thread(ThreadProc); _thread.Start(); }
public void Start(ClientStartInfo startInfo) { if (_disposed) { throw new ObjectDisposedException(nameof(PipeRpcServer)); } if (_started) { throw new InvalidOperationException("RPC server has already been started"); } _started = true; if (startInfo != null) { _clientHost = _mode == PipeRpcServerMode.Remote ? (IClientHost) new OutOfProcessHost(startInfo) : new InProcessHost(startInfo); _clientHost.Exited += _clientHost_Exited; } if (_mode == PipeRpcServerMode.Remote) { _inStream.DisposeLocalCopyOfClientHandle(); _outStream.DisposeLocalCopyOfClientHandle(); } if (_clientHost?.HasExited == true) { throw new PipeRpcException("RPC client failed to start"); } }
public OutOfProcessHost(ClientStartInfo startInfo) { _process = Process.Start(new ProcessStartInfo { FileName = startInfo.FileName, Arguments = PrintArguments(startInfo.Arguments), UseShellExecute = false, WorkingDirectory = startInfo.WorkingDirectory, CreateNoWindow = true }); _process.Exited += (s, e) => OnExited(); _process.EnableRaisingEvents = true; }