I use the Message Queue to send messages from one application to the other one (this has to work only on one particular machine)
I create the queue like this on the receiver side:
string queueName = ".\private$\WZMSGQ";
if (MessageQueue.Exists(queueName))
msgQueue = new MessageQueue(queueName);
else
msgQueue = MessageQueue.Create(queueName, false);
and after this I start the sender application, where I create the queue like that:
msgQueue = new MessageQueue(".\private$\WZMSGQ");
in the receiver Application I then retrieve new messages:
Message[] messages = msgQueue.GetAllMessages();
foreach (Message msg in messages){
doSomething();
}
Now I d like to do two things:
I would like to clear the message queue when instantiating the new MessageQueue instance on the receiver machine such that all old messages are gone. I d like to delete the message queue when the program ends, such that it does not exist anymore if I start the application the next time
How can I do that?