public void EndHandleMessages(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } RelayMessageListAsyncResult resultMessage = (RelayMessageListAsyncResult)asyncResult; if (resultMessage.Exception != null) { throw resultMessage.Exception; } }
private IEnumerator <ITask> HandleOutMessages(RelayMessageListAsyncResult asyncMessages) { try { counters.CountInputBytes(asyncMessages.Messages); foreach (var task in components.HandleOutMessages(asyncMessages)) { yield return(task); } } finally { counters.CountOutMessages(asyncMessages.Messages); const bool wasSynchronous = false; asyncMessages.CompleteOperation(wasSynchronous); } }
private IEnumerator<ITask> HandleOutMessages(RelayMessageListAsyncResult asyncMessages) { try { counters.CountInputBytes(asyncMessages.Messages); foreach (var task in components.HandleOutMessages(asyncMessages)) { yield return task; } } finally { counters.CountOutMessages(asyncMessages.Messages); const bool wasSynchronous = false; asyncMessages.CompleteOperation(wasSynchronous); } }
public IAsyncResult BeginHandleMessages(IList<RelayMessage> messages, object state, AsyncCallback callback) { RelayMessageListAsyncResult result; MessageList list = new MessageList(messages); messageTracer.WriteMessageInfo(messages); if (list.OutMessageCount > 0) { result = new RelayMessageListAsyncResult(list.OutMessages, state, callback); } else { result = new RelayMessageListAsyncResult(new List<RelayMessage>(0), state, callback); } try { counters.CountMessageList(messages); #region Assing SourceZone for each msg foreach (RelayMessage message in messages) { if (message.SourceZone == 0) { message.SourceZone = MyZone; } } #endregion if (list.InMessageCount > 0) { inMessagesPort.Post(list.InMessages); } if (list.OutMessageCount > 0) { if (outMessagesPort == null) { throw new InvalidOperationException("DataRelay is misconfigured. BeginHandleMessages was called without OutMessagesOnRelayThreads enabled."); } outMessagesPort.Post(result); } else //list.OutMessageCount == 0 // if there were no out messages we're done. { //we say it's sync because the callback is being called on the same thread const bool wasSynchronous = true; result.CompleteOperation(wasSynchronous); } } catch (Exception exc) { if (log.IsErrorEnabled) { log.ErrorFormat("Exception doing BeginHandleMessages: {0}", exc); } result.Exception = exc; //we say it's sync because the callback is being called on the same thread const bool wasSynchronous = true; result.CompleteOperation(wasSynchronous); } return result; }
public IAsyncResult BeginHandleMessages(IList <RelayMessage> messages, object state, AsyncCallback callback) { RelayMessageListAsyncResult result; MessageList list = new MessageList(messages); messageTracer.WriteMessageInfo(messages); if (list.OutMessageCount > 0) { result = new RelayMessageListAsyncResult(list.OutMessages, state, callback); } else { result = new RelayMessageListAsyncResult(new List <RelayMessage>(0), state, callback); } try { counters.CountMessageList(messages); #region Assing SourceZone for each msg foreach (RelayMessage message in messages) { if (message.SourceZone == 0) { message.SourceZone = MyZone; } } #endregion if (list.InMessageCount > 0) { inMessagesPort.Post(list.InMessages); } if (list.OutMessageCount > 0) { if (outMessagesPort == null) { throw new InvalidOperationException("DataRelay is misconfigured. BeginHandleMessages was called without OutMessagesOnRelayThreads enabled."); } outMessagesPort.Post(result); } else //list.OutMessageCount == 0 // if there were no out messages we're done. { //we say it's sync because the callback is being called on the same thread const bool wasSynchronous = true; result.CompleteOperation(wasSynchronous); } } catch (Exception exc) { if (log.IsErrorEnabled) { log.ErrorFormat("Exception doing BeginHandleMessages: {0}", exc); } result.Exception = exc; //we say it's sync because the callback is being called on the same thread const bool wasSynchronous = true; result.CompleteOperation(wasSynchronous); } return(result); }