Message Queue Question:

  • Thread starter Thread starter Charles Shao
  • Start date Start date
C

Charles Shao

Message Queue Question:

I'm trying to make a demo for MSMQ.
I send a message(string) on client and try to receive it in a daemon(Windows
service).
Now, I get a problem:

1. When I start the service in services manager, The start event will be
time out. but in fact, the service is running and in loop "for".
What can I to for this problem.

Thanks

Charles Shao :-)

================================================================
server.OnStart()
{
.....
for(;;)
{
crrMsg = Msmq1.Receive();
GlobalLog.write("Received Message:" + crrMsg.Body.ToString() + "\n" );
}
}// In fact, On start will never return .
 
Charles Shao said:
Message Queue Question:

I'm trying to make a demo for MSMQ.
I send a message(string) on client and try to receive it in a
daemon(Windows
service).
Now, I get a problem:

1. When I start the service in services manager, The start event will be
time out. but in fact, the service is running and in loop "for".
What can I to for this problem.

Thanks

Charles Shao :-)

================================================================
server.OnStart()
{
.....
for(;;)
{
crrMsg = Msmq1.Receive();
GlobalLog.write("Received Message:" + crrMsg.Body.ToString() + "\n" );
}
}// In fact, On start will never return .

The problem is that you need to return from OnStart within 30 seconds by
default.
So you need to spawn another thread to do the actual processing.

Willy.
 
Back
Top