/// <summary> /// 同步方法 /// </summary> /// <param name="ncmd"></param> /// <returns></returns> public object SendObj(NetCommand ncmd) { return SendObj(ncmd, 20); }
/// <summary> /// 同步方法 /// </summary> /// <param name="ncmd"></param> /// <returns></returns> public object SendObj(NetCommand ncmd, int timeout) { DateTime sdt = DateTime.Now; Send(ncmd); while (true) { DateTime now = DateTime.Now; TimeSpan ts = now - sdt; if (ts.TotalSeconds <= timeout) { if (Global.netData[ncmd.gid] != null) { object obj = Global.netData[ncmd.gid]; Global.netData.Remove(ncmd.gid); return obj; } } else return ""; Thread.Sleep(20); } }