利用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());

你可能感兴趣的:(messagequeue)