using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace StressClient { class Program { static void Main(string[] args) { try { System.Console.WriteLine("Begin YouYan Stress test..."); ConnectionManager cm = new ConnectionManager(); // 线程列表 List thread_list = new List(); // 循环添加连接客户端 for (int i = 0; i < 100; i++) { int mn = 100000 + i; string clientId = $"iwb{mn:D6}"; //DotnetSocketClient _client = new DotnetSocketClient(clientId); AsyncClient _client = new AsyncClient(i, clientId); // 创建线程,使之执行该类的Run方法 Thread oThread = new Thread(new ThreadStart(_client.Run)); oThread.Start(); cm.Add(oThread); } /*Alpha oAlpha = new Alpha(); Thread oThread = new Thread(new ThreadStart(oAlpha.Beta)); oThread.Start();*/ while (true) { string cmd = System.Console.ReadLine(); if (cmd.CompareTo("quit") == 0) break; } // 停止工作线程 cm.Stop(); } catch(Exception e) { System.Console.WriteLine(e.Message); } System.Console.WriteLine("Enter any key to stop"); System.Console.ReadKey(); } } }