MSMQ as timer

K

Kimmo Laine

Hi,

is there a (built in) way to use MSMQ as a "timer":


MessageQueue mq;
// . . .
mq.ReceiveCompleted += new ReceiveCompletedEventHandler( MyMSMQHandler );
// . . .

private void Foo() {
mq.Send( /* Send MY_MSG_CODE without delay *& );
}

private void MyMSMQHandler( object sender, ReceiveCompletedEventArgs e ) {

MessageQueue q = ( MessageQueue )sender;
Message msg = q.EndReceive( e.AsyncResult );

if( msg.AppSpecific == MY_MSG_CODE ) {
// If i can do something - do it
} else {
// Wait a moment and try again
q.Send( /* Send MY_MSG_CODE with delay */ );
}

q.BeginReceive();

}


thx

Kimmo Laine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top