private void OnPublishChannelCreated(PublishChannelCreatedEvent @event)
        {
            foreach (var channel in unconfirmedChannelRequests.Keys)
            {
                ConcurrentDictionary <ulong, TaskCompletionSource <object> > confirmations;
                if (!unconfirmedChannelRequests.TryRemove(channel, out confirmations))
                {
                    continue;
                }
                foreach (var deliveryTag in confirmations.Keys)
                {
                    TaskCompletionSource <object> confirmation;
                    if (!confirmations.TryRemove(deliveryTag, out confirmation))
                    {
                        continue;
                    }

#if NETFX
                    confirmation.TrySetExceptionAsynchronously(new PublishInterruptedException());
#else
                    confirmation.TrySetException(new PublishInterruptedException());
#endif
                }
            }
            unconfirmedChannelRequests.Add(@event.Channel, new ConcurrentDictionary <ulong, TaskCompletionSource <object> >());
        }
Exemplo n.º 2
0
        private void OnPublishChannelCreated(PublishChannelCreatedEvent publishChannelCreatedEvent)
        {
            Preconditions.CheckNotNull(publishChannelCreatedEvent.Channel, "model");

            var outstandingConfirms = new List <ConfirmActions>(dictionary.Values);

            foreach (var outstandingConfirm in outstandingConfirms)
            {
                outstandingConfirm.Cancel();
                PublishWithConfirmInternal(
                    publishChannelCreatedEvent.Channel,
                    outstandingConfirm.PublishAction,
                    outstandingConfirm.TaskCompletionSource);
            }
        }