protected void AbandonStartedUnits() { if (IsBusy) { AsciiProtocolUnit.FireFinished(_currentUnit); } while (_unitQueue.Count > 0) { AsciiProtocolUnit.FireFinished((AsciiProtocolUnit)_unitQueue.Pop()); } }
public virtual void StartUnit(int priority, AsciiProtocolUnit unit) { if (!Core.NetworkAP.IsOwnerThread) { Core.NetworkAP.QueueJob(JobPriority.Immediate, _startDelegate, priority, unit); } else { _unitQueue.Push(priority, unit); if (!IsBusy) { StartNextUnitAsync(); } } }
private void sendUnit_Finished(AsciiProtocolUnit unit) { AsciiSendLineUnit sendUnit = (AsciiSendLineUnit)unit; if (!(_lineSent = sendUnit.LineSent)) { FireFinished(); } else { _connection.AfterReceive += new MethodInvoker(_connection_AfterReceive); _connection.LineReceived += new LineDelegate(_connection_LineReceived); _connection.OperationFailed += new MethodInvoker(FireFinished); _connection.SkipReceivedStream(); _connection.Receive(); } }
private void connectUnit_Finished(AsciiProtocolUnit unit) { AsciiConnectUnit connectUnit = (AsciiConnectUnit)unit; if (!(_connected = connectUnit.Connected)) { FireFinished(); } else { _connection.AfterReceive += new MethodInvoker(FireFinished); _connection.LineReceived += new LineDelegate(_connection_LineReceived); _connection.OperationFailed += new MethodInvoker(FireFinished); _connection.SkipReceivedStream(); _connection.Receive(); } }
private void StartNextUnit() { if (!Core.NetworkAP.IsOwnerThread) { StartNextUnitAsync(); } else { if (_unitQueue.Count > 0) { AsciiProtocolUnit unit = (AsciiProtocolUnit)_unitQueue.Pop(); unit.Finished += new AsciiProtocolUnitDelegate(unit_Finished); _currentUnit = unit; if (LastSocketException == null) { unit.Start(this); } else { Close(); } } } }
protected internal static void FireFinished(AsciiProtocolUnit unit) { unit.FireFinished(); }
protected static void StartUnit(AsciiProtocolUnit unit, AsciiTcpConnection connection) { unit.Start(connection); }
private void unit_Finished(AsciiProtocolUnit unit) { _currentUnit = null; CloseIdleConnectionAfterTimeout(); StartNextUnitAsync(); }