Message Queue Question:

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 .
 
W

Willy Denoyette [MVP]

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.
 

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