Why do u want to poll the queue??? U can set up MSMQ triggers which are event based. U just tell the trigger if a msg appears on this queue .....such and such method shud b called in ur Component.
That's it!! - Regards Nishant Pant -----Original Message----- From: Zecharya Bar [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 8:29 AM To: [EMAIL PROTECTED] Subject: [ADVANCED-DOTNET] Message Queue and Windows Service Hi, I'm beginning to experiment with Microsoft Message Queues and have run into a simple problem. I would like a Windows Service I'm creating to monitor continuously a MSMQ, and upon receiving a message, call another method. How do I get the service to continually check the queue? I've tried putting the Receive() function in an infinite loop in the OnStart method (see code), but of course that keeps the service from installing! I'd appreciate any advice! Bar *** my code *** protected override void OnStart(string[] args) { string queuePath = @".\private$\myQueue"; MessageQueue myQueue; if (! MessageQueue.Exists(queuePath)) { MessageQueue.Create(queuePath); } myQueue = new MessageQueue(queuePath); // ...and now the infinite loop... while (true) { Message myMessage = myQueue.Receive(); ProcessMessage(myMessage.Body.ToString()); // call to another method } }
