MessageQueue消息队列的使用

           //Send
            MessageQueue MQueue = new MessageQueue(".\\private$\\MQDemo");
            System.Messaging.Message Msg = new System.Messaging.Message();
            Msg.Body = textBox1.Text;
            Msg.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] { typeof(string) });
            MQueue .Send(Msg);
        
           //Receive         
           MessageQueue MQueue = new MessageQueue(".\\private$\\MQDemo");
           System.Messaging.Message Msg = MQueue.Receive();
           Msg.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] { typeof(string) }); 
           MessageBox.Show(Msg.Body.ToString());

posted on 2013-02-19 15:02  宋时明月  阅读(416)  评论(0编辑  收藏  举报

导航