示例#1
0
        protected override void OnClose(TimeSpan timeout)
        {
            if (_AcceptChannelAsyncResult == null)
            {
                return;
            }

            _AcceptChannelAsyncResult.Complete();

            _AcceptChannelAsyncResult.Callback?.Invoke(_AcceptChannelAsyncResult);
        }
示例#2
0
        public IAsyncResult BeginWaitForRequest(TimeSpan timeout, AsyncCallback callback, object state)
        {
            ThrowIfDisposedOrNotOpen();

            var asyncResult = new GenericAsyncResult(false, state, timeout, callback, false);

            var consumer = new EventingBasicConsumer(Model);

            consumer.Received += (a, b) =>
            {
                asyncResult.Complete();

                _CurrentRabbitMqMessage = b.AsRabbitMqMessage();

                callback?.Invoke(asyncResult);
            };

            Model.BasicConsume(ServiceConfiguration.ServiceQueue, false, consumer);

            return(asyncResult);
        }