Exemplo n.º 1
0
        /// <summary>
        ///     Start or connect to the server.
        /// </summary>
        public override Task Start()
        {
            ServerExitCompletion = new TaskCompletionSource <object>();

            _serverStartInfo.CreateNoWindow         = true;
            _serverStartInfo.UseShellExecute        = false;
            _serverStartInfo.RedirectStandardInput  = true;
            _serverStartInfo.RedirectStandardOutput = true;

            Process serverProcess = _serverProcess = new Process
            {
                StartInfo           = _serverStartInfo,
                EnableRaisingEvents = true
            };

            serverProcess.Exited += ServerProcess_Exit;

            if (!serverProcess.Start())
            {
                throw new InvalidOperationException("Failed to launch language server .");
            }

            ServerStartCompletion.TrySetResult(null);

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Start or connect to the server.
        /// </summary>
        /// <returns>
        ///     A <see cref="Task"/> representing the operation.
        /// </returns>
        public override async Task Start()
        {
            ServerExitCompletion = new TaskCompletionSource <object>();

            ServerInputStream  = new NamedPipeServerStream(BaseName + "/in", PipeDirection.Out, 2, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, inBufferSize: 1024, outBufferSize: 1024);
            ServerOutputStream = new NamedPipeServerStream(BaseName + "/out", PipeDirection.In, 2, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, inBufferSize: 1024, outBufferSize: 1024);
            ClientInputStream  = new NamedPipeClientStream(".", BaseName + "/out", PipeDirection.Out, PipeOptions.Asynchronous);
            ClientOutputStream = new NamedPipeClientStream(".", BaseName + "/in", PipeDirection.In, PipeOptions.Asynchronous);

            // Ensure all pipes are connected before proceeding.
            await Task.WhenAll(
                ServerInputStream.WaitForConnectionAsync(),
                ServerOutputStream.WaitForConnectionAsync(),
                ClientInputStream.ConnectAsync(),
                ClientOutputStream.ConnectAsync()
                );

            ServerStartCompletion.TrySetResult(null);
        }