// Service Tcp/IP requests. public void StartMethod() { // Stopping the main thread will terminate the program. System.Threading.Thread.CurrentThread.IsBackground = true; Logger.WriteEntry("The TCP Server is starting."); // Start listening for connections. TcpListener tcpListener = new TcpListener(IPAddress.Any, ServerPort); tcpListener.Start(); // Dispatch service to each connection. ThreadDispatcher.StartDispatching(tcpListener, Logger, ProtocolFactory, AppDocument); }