public void DataRequest(ushort targetShortAddr, ref Frame sdu, byte sduHandle, DataConfirmHandler handler) { if (!_started) { if (handler != null) { handler.Invoke(this, sduHandle, Status.NotRunning); } return; } if (targetShortAddr == _localShortAddress) { // deliver frame to ourself if (handler != null) { handler.Invoke(this, sduHandle, Status.Success); } DataIndicationHandler ind = _dataIndicationHandler; if (ind != null) { ind.Invoke(this, targetShortAddr, targetShortAddr, sdu); sdu = null; } return; } DataRequestItem newItem = new DataRequestItem(targetShortAddr, ref sdu, sduHandle, handler); OutboundFragmentationMessage outMsg = null; bool queueFull = false; lock (_lock) { // check if one can send directly the message. if (null == _outboundAssociations.GetFragmentationMessage(_localShortAddress, targetShortAddr)) { outMsg = CreateNewOutboundMessage(newItem); } else { // there is already a message being sent to this address. Store to queue. if (!_dataRequestQueueSet.Add(newItem)) { queueFull = true; } } } // release the lock before calling method in FragmentMessage class if (outMsg != null) { outMsg.SendNextDataFragment(true); } else if (queueFull) { // queue is full. if (handler != null) { handler.Invoke(this, sduHandle, Status.Busy); } newItem.Dispose(); } }