private void OnSendNextSegment(ActionCompletedUnit actionUnit) { if ((TxOptions & TransmitOptions.TransmitOptionAcknowledge) == TransmitOptions.TransmitOptionAcknowledge) { var sendData = actionUnit.Action as SendDataOperation; if (sendData.SpecificResult.TransmitStatus == TransmitStatuses.CompleteNoAcknowledge) { SpecificResult.SubstituteStatus = SubstituteStatuses.Failed; SetStateFailed(actionUnit); } } Thread.Sleep(RELAXED_TIMING_DELAY); if (_dataOffset < _data.Length) { _nextSegmentSendOperation.NewToken(); _nextSegmentSendOperation.Data = CreateSubsequentSegmentCmd(_data, _dataOffset); if (_dataOffset + _subsequentSegmentPayloadSize >= _data.Length) { if (_segmentCompleteExpect.Token.State == ActionStates.Running) { _segmentCompleteExpect.Token.Reset(SEGMENT_COMPLETE_TIMEOUT); } else { _segmentCompleteExpect.NewToken(); actionUnit.AddFirstNextActionItems(_segmentCompleteExpect); } } _dataOffset += _subsequentSegmentPayloadSize; } }
private void OnTimeElapsed(TimeElapsedUnit timeElapsedUnit) { _firstSegmentSendOperation.NewToken(); _firstSegmentSendOperation.Data = CreateFirstSegmentCmd(_data); timeElapsedUnit.SetNextActionItems(_firstSegmentSendOperation); _nextSegmentSendOperation.NewToken(); _sendNextSegmentCompletedUnit.SetNextActionItems(_nextSegmentSendOperation); }