Exemplo n.º 1
0
        private void ReceiveMessages(object sender, DoWorkEventArgs e)
        {
            MessageQueue msMq = null;

            if (!MessageQueue.Exists(MessageConstants.ObjectMessageQueue))
            {
                msMq = MessageQueue.Create(MessageConstants.ObjectMessageQueue);
            }
            else
            {
                msMq = new MessageQueue(MessageConstants.ObjectMessageQueue);
            }

            while (true)
            {
                try
                {
                    // msMq.Formatter = new XmlMessageFormatter(new Type[] {typeof(string)});
                    msMq.Formatter = new XmlMessageFormatter(new Type[] { typeof(RateObject) });

                    RateObject rate = (RateObject)msMq.Receive().Body;
                    worker.ReportProgress(0, rate);
                }
                catch (MessageQueueException ee)
                {
                    MessageBox.Show(ee.Message);
                }
                catch (Exception eee)
                {
                    MessageBox.Show(eee.Message);
                }
                finally
                {
                    msMq.Close();
                }

                Thread.Sleep(500);
            }
        }
Exemplo n.º 2
0
        private void UpdateList(object sender, ProgressChangedEventArgs e)
        {
            RateObject obj = (RateObject)e.UserState;

            rateObjects.Add(obj);
        }