Exemple #1
0
        private void WaitAnyCallback(IAsyncResult asyncResult)
        {
            AsyncResult         ar              = (AsyncResult)asyncResult;
            RemoteAsyncDelegate remoteDel       = (RemoteAsyncDelegate)ar.AsyncDelegate;
            Message             responseMessage = remoteDel.EndInvoke(asyncResult);
            CallbackState       state           = (CallbackState)ar.AsyncState;

            Message originalMessage = state.OriginalMessage;
            string  remoteUrl       = state.RemoteUrl;

            lock (ReplyResultQueue)
            {
                ReplyResultQueue.TryGetValue(originalMessage, out var replyResult);
                if (replyResult == null)
                {
                    return;
                }

                // save the result
                replyResult.AddResult(remoteUrl, responseMessage);

                // if ANY result, notify the caller (the one who initiated the multi-cast)
                if (replyResult.IsDone())
                {
                    PulseMessage(originalMessage);
                }
            }
        }
Exemple #2
0
        private void MulticastSingleUrl(string remoteURL, Message message, AsyncCallback asyncCallback)
        {
            var remotingEndpoint = GetRemoteEndpoint(remoteURL);

            try {
                RemoteAsyncDelegate remoteDel = remotingEndpoint.OnReceiveMessage;
                CallbackState       state     = new CallbackState(message, remoteURL);
                remoteDel.BeginInvoke(message, asyncCallback, state);
            }
            catch (Exception e) {
                Log("Server at " + remoteURL + " is unreachable.");
                throw;
            }
        }