public RunClient ( Object threadContext ) : void | ||
threadContext | Object | |
Résultat | void |
public static void StartServerBlocked(Object threadContext) { int port = (int)threadContext; IPAddress localAddr = IPAddress.Parse("127.0.0.1"); TcpListener server = new TcpListener(localAddr, port); server.Start(); DebuggerAttached = true; Debugger.OnResult += SendBack; ThreadPool.QueueUserWorkItem(StartProcessing, null); while (true) { Console.Write("Waiting for a connection on {0}... ", port); // Perform a blocking call to accept requests. TcpClient socket = server.AcceptTcpClient(); DebuggerClient client = new DebuggerClient(); m_clients.Add(client); ThreadPool.QueueUserWorkItem(o => client.RunClient(socket)); Thread.Sleep(1000); } }
static void StartServerBlocked(Object threadContext) { if (s_serverStarted) { return; } s_serverStarted = true; DebuggerAttached = true; Debugger.OnResult += SendBack; Debugger.OnSendFile += SendFile; ThreadPool.QueueUserWorkItem(StartProcessing, null); while (DebuggerAttached) { Console.Write("Waiting for a connection... "); try { // Perform a blocking call to accept requests. TcpClient socket = s_server.AcceptTcpClient(); DebuggerClient client = new DebuggerClient(); m_clients.Add(client); ThreadPool.QueueUserWorkItem(o => client.RunClient(socket)); } catch (Exception exc) { string err = string.Format("Exception running server: {0}", exc.Message); Console.Write(err); } Thread.Sleep(1000); } Console.Write("Stopped listening for requests"); s_serverStarted = false; }