private void SendTimer_Elapsed(object sender, ElapsedEventArgs e) { if (_sendTimerActive) { return; } try { _sendTimerActive = true; if (_sendBuffer.Count == 0) { return; } //Debug.WriteLine(_itelex.GetSendBufferCount()); while (_itelex.GetSendBufferCount() < 5 && _sendBuffer.Count > 0) { _itelex.SendAsciiChar(_sendBuffer.Dequeue()); } UpdateSend?.Invoke(); } finally { _sendTimerActive = false; } }
private void SendTimer_Elapsed(object sender, ElapsedEventArgs e) { if (_sendBuffer.Count == 0 || _sendTimerActive) { return; } try { _sendTimerActive = true; // send one character if (_itelex.GetSendBufferCount() < 5 && _sendBuffer.Count > 0) { if (_sendBuffer.TryDequeue(out char chr)) { _itelex.SendAsciiChar(chr); } } /* * if (_configData.OutputSpeed == 0) * { // max. speed * while (_itelex.GetSendBufferCount() < 5 && _sendBuffer.Count > 0) * { * lock (_sendBufferLock) * { * _itelex.SendAsciiChar(_sendBuffer.Dequeue()); * } * } * } * else * { * // send one character * if (_itelex.GetSendBufferCount() < 5 && _sendBuffer.Count > 0) * { * _itelex.SendAsciiChar(_sendBuffer.Dequeue()); * } * } */ UpdateSend?.Invoke(); } finally { _sendTimerActive = false; } }