/// <summary> /// Main thread /// </summary> private void threadAVCLANTxTask() { MessageContainer pending_to_send; while (ThreadRunning) { try { if (AVCLAN_MessagesToSend.Count() > 0) { pending_to_send = AVCLAN_MessagesToSend.Dequeue(); if (AVCLANSerialPort.isPortOpen()) { SLIPEncoderObject.encodeSLIPMessage(pending_to_send.MessageObject); if (SLIPEncoderObject.IsEncodeComplete) { AVCLANSerialPort.WriteData(SLIPEncoderObject.getEncodeMessage()); /* Notify listeners message */ notifyAVCLANListeners(pending_to_send); } } } else { AVCLAN_TxMessageWaitSemaphore.WaitOne(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } }
/// <summary> /// Main thread /// </summary> private void threadSnifferTxTask() { MessageContainer pending_to_send; while (ThreadRunning) { try { if (AVCLAN_MessagesToSend.Count() > 0) { pending_to_send = AVCLAN_MessagesToSend.Dequeue(); if ((SnifferSerialPort != null) && SnifferSerialPort.isPortOpen()) { SLIPEncoderObject.encodeSLIPMessage(pending_to_send.MessageObject); if (SLIPEncoderObject.IsEncodeComplete) { SnifferSerialPort.WriteData(SLIPEncoderObject.getEncodeMessage()); } } } else { SnifferTxMessageWaitSemaphore.WaitOne(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } }