public void Run() { Thread t = new Thread(() => { NetStreamMultiSender s = new NetStreamMultiSender(RTSConstants.MC_ADDR, RTSConstants.MC_GAME_PORT_MIN); while(running) { if(commands.Count > 0) { string m; if(commands.TryDequeue(out m)) { Console.WriteLine("Sent Command [{0}]", m); s.Send(m); } } } s.Dispose(); }); running = true; t.Start(); bool input = true; while(input) { string c = Console.ReadLine(); switch(c) { case "exit": case "quit": case "q": input = false; break; default: commands.Enqueue(c); break; } } running = false; t.Join(); }
public void Run() { Thread t = new Thread(() => { NetStreamMultiSender s = new NetStreamMultiSender(RTSConstants.MC_ADDR, RTSConstants.MC_GAME_PORT_MIN); while (running) { if (commands.Count > 0) { string m; if (commands.TryDequeue(out m)) { Console.WriteLine("Sent Command [{0}]", m); s.Send(m); } } } s.Dispose(); }); running = true; t.Start(); bool input = true; while (input) { string c = Console.ReadLine(); switch (c) { case "exit": case "quit": case "q": input = false; break; default: commands.Enqueue(c); break; } } running = false; t.Join(); }