public static void End() { if (Message != null) { Message.End(); Message = null; if (channel != null) { ChannelServices.UnregisterChannel(channel); channel = null; } } if (ServerProcess != null) { if (!ServerProcess.HasExited) { ServerProcess.Kill(); } ServerProcess.Dispose(); ServerProcess = null; } }
/// <summary> /// Dispose of resources being used by the client. /// </summary> public void Dispose() { LspConnection connection = Interlocked.Exchange(ref _connection, null); connection?.Dispose(); ServerProcess serverProcess = Interlocked.Exchange(ref _process, null); serverProcess?.Dispose(); }
public void dispose_removes_from_server() { var sut = new ServerProcess( GetListenerMock().Object, () => GetMessageHandlerMock().Object, null); var serverMock = new Mock<IServer>(); serverMock.Setup(o => o.Remove(It.IsAny<ServerProcess>())).Verifiable(); sut.Server = serverMock.Object; sut.Dispose(); serverMock.Verify(); GC.Collect(); }
public void disposed_process_is_removed() { using (var server = GetServer()) { server.Add(new ServerProcess(GetListener(), GetHandler, null)); var process = new ServerProcess(GetListener(), GetHandler, null); server.Add(process); Assert.Equal(2, server.Processes.Count()); process.Dispose(); Assert.Equal(1, server.Processes.Count()); Assert.DoesNotContain(process, server.Processes); } }
public void HandleServerExit(int code) { Console.WriteLine(string.Format("Server process completed with code = {0}", code)); if (code == 0) { ConsecutiveErrors = 0; } else { ++ConsecutiveErrors; } SetStatus(ServerStatus.Stopped); ServerProcess.Dispose(); ServerProcess = null; }
private void StartServer(string configKey) { //Should exist ConfigInformation info = this.ConfigDictionary[configKey]; ServerProcess sProcess = new ServerProcess("ServerLoader.exe", info); //Remove the sever process from the process list on exited. sProcess.OnExited += () => { StopServerProcess(sProcess); ServerProcess proc; ServerProcesses.TryRemove(sProcess.UniqueProcessID, out proc); this.UpdateProcessList(); sProcess.Dispose(); }; this.ServerProcesses.TryAdd(sProcess.UniqueProcessID, sProcess); this.UpdateProcessList(); }
private void StopServerProcess(ServerProcess process) { process.ShutdownServer(); process.Dispose(); }