private void ThrowIfFail(bool result, CommQueue queue) { if (!result) { string msg; var error = queue.GetLastError(connect, out msg); throw new Exception(msg); } }
/// <summary> /// Handles the reception and transmission of messages /// </summary> protected virtual void CommManager() { while (!isStopping) { lock (CommQueue) { if (CommQueue.Count > 0) { if (CommQueue.Peek().TargetID == ID) { OnMessageRxEvent(CommQueue.Dequeue()); } } } if (TxQueue.Count > 0) { CommQueue.Enqueue(TxQueue.Dequeue()); } Thread.Sleep(100); } }