private void loop() { try { m_listener.Start(); } catch (Exception e) { Debug.WriteLine("Cannot start thread " + e); return; } Debug.WriteLine("HTTP LISTENER STARTED"); while (!m_terminated) { try { IHandler handler = HandlerFactory.getHandler(m_listener.AcceptTcpClient()); if(m_terminated) { Thread.Sleep(1000); return; } if (handler != null) { handler.handle(); } Thread.Sleep(1); } catch (Exception e) { Debug.WriteLine("get TCP RECEIVE fault " + e); } } // while } // loop