/// <summary> /// 启动线程,循环,将接收的包加入栈 /// </summary> /// <param name="actLog"></param> public static void addToQueue(Action <string> actLog) { ThreadHelper.start(() => { var m = new SocketHelper() { actLog = actLog, isDisplayLog = true }; while (true) { try { var myParm = m.Receive(ServerInfo.myConfig); var myParm1 = myParm.copy(); if (AppHelper._lstApp == null) { AppHelper._lstApp = new List <AppHelper>(); } //入栈 var app = new AppHelper() { myParm = myParm1, actLog = m.actLog, }; AppHelper._lstApp.Add(app);// SocketHelper.sendStringToClient("工具已启动,请等待...", opType._op_log, myParm1, actLog); } catch (Exception ex) { actLog(ex.Message); break; } } }, actLog); }
/// <summary> /// 启动接收,循环,执行,直到,为结束标记 /// </summary> /// <param name="myParm"></param> /// <param name="m"></param> public static void execInWhile(Parm myParm, SocketHelper m) { while (true) { try { var myParm2 = m.Receive(new ServerInfo() { Ip = myParm.LocalEndPoint.Address.ToString(), Port = myParm.LocalEndPoint.Port.ToString(), }); var app = new AppHelper() { myParm = myParm2, actLog = m.actLog, }; app.exec(); System.Threading.Thread.Sleep(50); if (myParm2.op.EndsWith("88")) { break; } } catch (Exception ex) { m.actLog(ex.Message); break; } } }