private I waitReplyMonitor(ReplyMonitor <O, I> mon) { if (mon.getReply() == null) { mon.waitReply(timeout); } sentCommandsQueue.Remove(mon); if (mon.getReply() != null) { return(mon.getReply()); } throw new IOException(String.Format(Cres.get().getString("cmdTimeout"), mon.getCommand())); }
public ReplyMonitor <O, I> sendCommand(O cmd) { if (!thread.IsAlive) { lock (sentCommandsQueue) { foreach (var cur in sentCommandsQueue) { cur.setReply(null); } } lock (unsentCommandsQueue) { foreach (var cur in unsentCommandsQueue) { cur.setReply(null); } } throw new DisconnectionException(Cres.get().getString("cmdDisconnected")); } var mon = new ReplyMonitor <O, I>(cmd); if (sendImmediately) { addSentCommand(mon); doSend(cmd); } else { unsentCommandsQueue.enqueue(mon); } return(mon); }
protected void addSentCommand(ReplyMonitor <O, I> mon) { sentCommandsQueue.Add(mon); }