Apache.NMS.ActiveMQ.Util.SimplePriorityMessageDispatchChannel.DequeueNoWait C# (CSharp) Method

DequeueNoWait() public method

public DequeueNoWait ( ) : MessageDispatch
return MessageDispatch
        public MessageDispatch DequeueNoWait()
        {
            MessageDispatch result = null;

            lock(this.mutex)
            {
                if( Closed || !Running || Empty )
                {
                    return null;
                }

                result = RemoveFirst();
            }

            return result;
        }

Usage Example

        public void TestEnqueueFront()
        {
            SimplePriorityMessageDispatchChannel channel = new SimplePriorityMessageDispatchChannel();
            MessageDispatch dispatch1 = new MessageDispatch();
            MessageDispatch dispatch2 = new MessageDispatch();

            channel.Start();

            Assert.IsTrue( channel.Empty == true );
            Assert.IsTrue( channel.Count == 0 );

            channel.EnqueueFirst( dispatch1 );

            Assert.IsTrue( channel.Empty == false );
            Assert.IsTrue( channel.Count == 1 );

            channel.EnqueueFirst( dispatch2 );

            Assert.IsTrue( channel.Empty == false );
            Assert.IsTrue( channel.Count == 2 );

            Assert.IsTrue( channel.DequeueNoWait() == dispatch2 );
            Assert.IsTrue( channel.DequeueNoWait() == dispatch1 );
        }
All Usage Examples Of Apache.NMS.ActiveMQ.Util.SimplePriorityMessageDispatchChannel::DequeueNoWait