MessageQueue.Exists(String value) : MessageQueue « System.Messaging « C# / C Sharp by API






MessageQueue.Exists(String value)

  

using System;
using System.Messaging;

[Serializable]
class MyMessage {
    private string data;
    public MyMessage(string data) {
        this.data = data;
    }


    public override string ToString() {
        return data;
    }

}

class Program {
    static void Main(string[] args) {
        try {
            if (!MessageQueue.Exists(@".\Private$\MyPrivateQueue")) {
                MessageQueue.Create(@".\Private$\MyPrivateQueue");
            }
            MessageQueue queue = new MessageQueue(@".\Private$\MyPrivateQueue");
            queue.Formatter = new BinaryMessageFormatter();

            queue.Send("Sample Message", "Label");

            MyMessage m = new MyMessage("xxx");
            queue.Send(m, "Binary Test");
        } catch (MessageQueueException ex) {
            Console.WriteLine(ex.Message);
        }
    }
}

   
    
  








Related examples in the same category

1.new MessageQueue
2.MessageQueue.Create(String value)
3.MessageQueue.Send