Пример #1
0
        public void RetrieveMessageFromAnotherPersonQueue()
        {
            anotherPersonQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(AnotherPerson) });

            Message[]     messages = anotherPersonQueue.GetAllMessages();
            StringBuilder builder  = new StringBuilder();

            var isOK = messages.Count() > 0 ? true : false;

            foreach (Message m in messages)
            {
                try
                {
                    AnotherPerson person  = new AnotherPerson();
                    var           command = (AnotherPerson)m.Body;
                    person.Name = command.Name;
                    person.Age  = command.Age;
                    builder.Append(person.ToString() + "\n");
                }
                catch (MessageQueueException ex)
                {
                }
            }
            messageTextBlock.Text += builder.ToString();
        }