> -----Original Message----- > From: Saravana Prasad S [mailto:[EMAIL PROTECTED] > The problem is the reader thread can not keep sending > millions of messages to MSMQ as there is a memory limit. I > treid to send as mamy messages as possible to msmq. But after > sending two and a half million messages, the MSMQ threw an > error saying "Insufficient Memory". So I need to make reader > thread sleep for some time once it sends a million messages > and wake up after some time and start sending messages. Once > it wakes up, I need to know the number of messages in the > MSMQ so that It can send messages accordingle tp prevent from > crossing the memory limit.
Wouldn't the easiest thing to do would be to catch the exception, sleep for a set amount of time say 10 seconds then try again if it fails again then increase the sleep amout, say double, then keep trying while doubling the sleep time. What you may want is a threshold which the sleep time doesn't increase over, or a maximum number of times it can fail before it gives up, logs an error and the message (so that it can be resent later), in case there is a big problem like the computer the queue is on is down, the msmq service is stopped, etc. Chris =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com