public void InvokeSend(AbstractCommand command, int sleepMilSeconds) { lock (_lockItem) { _log.Debug("Invoke send"); _buffer.Remove(0, _buffer.Length); _serialPort.WriteLine(command.CompleteCommand()); _log.Debug("Invoke send success and wait " + sleepMilSeconds); Thread.Sleep(sleepMilSeconds); _buffer.Remove(0, _buffer.Length); } }
public string Send(AbstractCommand command) { lock (_lockItem) { try { _buffer.Remove(0, _buffer.Length); ThreadPool.QueueUserWorkItem(delegate { _serialPort.WriteLine(command.CompleteCommand()); }); return WaitReturn(command); } finally { _log.Info("Complete receive is: " + _buffer.ToString()); _buffer.Remove(0, _buffer.Length); } } }