public AsyncQueueReader(InputQueue <T> inputQueue, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.inputQueue = inputQueue; if (timeout != TimeSpan.MaxValue) { this.timer = new Timer(timerCallback, this, timeout, TimeSpan.FromMilliseconds(-1)); } }
/// <summary> /// Tries to dequeue the next message. /// </summary> /// <param name="result">The result.</param> /// <param name="message">The message.</param> /// <returns></returns> public bool TryDequeue(IAsyncResult result, out T message) { message = null; TypedAsyncResult <T> completedResult = result as TypedAsyncResult <T>; if (completedResult != null) { message = TypedAsyncResult <T> .End(result); } else if (result.CompletedSynchronously == false) { InputQueue <T> .AsyncQueueReader completedResult2 = result as InputQueue <T> .AsyncQueueReader; InputQueue <T> .AsyncQueueReader.End(result, out message); } return(result.IsCompleted); }
/// <summary> /// Initializes a new instance of the <see cref="NmsInputChannelListener"/> class. /// </summary> /// <param name="transportElement">The binding element.</param> /// <param name="context">The context.</param> internal NmsInputChannelListener(NmsTransportBindingElement transportElement, BindingContext context) : base(context.Binding) { _bufferManager = BufferManager.CreateBufferManager(transportElement.MaxBufferPoolSize, (int)transportElement.MaxReceivedMessageSize); MessageEncodingBindingElement messageEncoderBindingElement = context.BindingParameters.Remove <MessageEncodingBindingElement>(); _messageEncoderFactory = (messageEncoderBindingElement != null) ? messageEncoderBindingElement.CreateMessageEncoderFactory() : NmsConstants.DefaultMessageEncoderFactory; _channelQueue = new InputQueue <IInputChannel>(); _currentChannelLock = new object(); _destinationName = transportElement.Destination; _destinationType = transportElement.DestinationType; _uri = new Uri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress); Tracer.DebugFormat("Listening to {0} at {1}/{2}", _destinationType, _uri, _destinationName); }
/// <summary> /// Initializes a new instance of the <see cref="NmsInputQueueChannelBase<T>"/> class. /// </summary> /// <param name="factory">The factory that was used to create the channel.</param> /// <param name="localAddress">The local address of the channel.</param> public NmsInputQueueChannelBase(ChannelListenerBase factory, EndpointAddress localAddress) : base(factory) { _localAddress = localAddress; _messageQueue = new InputQueue <T>(); }
public WaitQueueReader(InputQueue <T> inputQueue) { this.inputQueue = inputQueue; waitEvent = new ManualResetEvent(false); }