void CreateRobot() { if (_count >= _maxCol * _maxRow) { Console.WriteLine($"too many robot.limit:{_maxRow*_maxCol}"); return; } int row = _count / _maxCol; int col = _count % _maxCol; RobotAgent r = new RobotAgent(_count, row, col); _robots.Add(_count, r); _count++; _grid.Children.Add(r.Btn); }
void RecvCB(IAsyncResult r) { try { RobotAgent agent = (RobotAgent)r.AsyncState; int length = agent._s.EndReceive(r); List <Packet> plist = new List <Packet>(); pr.process(_recvBuf, 0, length, plist); foreach (var p in plist) { //string s = pr.ReadString(p); //Trace.WriteLine($"Receive:{length},con:{s}"); } _s.BeginReceive(_recvBuf, 0, _recvBuf.Length, SocketFlags.None, RecvCB, this); } catch (Exception e) { Trace.WriteLine($"Exception:{e}"); } }