windows service questions

Z

ZQ

Hi all!

I have few questions regarding .net windows services

1. are onStart, onStop and other "system" events invoked in separate threads
than msmq events?
2. if so, is there a way for the onStop event to wait with stopping the
service until pending msmq events are finished?
3. if not, does that mean that the onStop event would actually be invoked
after all pending events are finished?

thanks!

Z.
 
K

Kevin Spencer

Services and MSMQ (which is also a service) have nothing to do with each
other, unless you tell them to. Every service runs in its own process. The
Starting and Stopping of services is not a concern of MSMQ. MSMQ is a
messenger. It queues messages, and delivers them when it can. If a service
stops, and then starts later, the message will still be there.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
 
Z

ZQ

Ok. Thanx for your quick response.
However.

In my win. service, I have configured it to asynchronously fire up an event
every time a message arrives into a message queue. Once it fires, I
endreceive the
message (and deserialize it), and process the received object. The
processing
takes awhile, and my real question is - if an administrator stops the
service while
the service is processing the message, will it kill the thread in which it
processes the message?
 
K

Kevin Spencer

if an administrator stops the service while
the service is processing the message, will it kill the thread in which it
processes the message?

Not necessarily. The Stop event sends a message to the service application
to stop. It doesn't kill the thread. That's why there's an event handler
there. But make sure that you account for the Stop event, and don't take too
long to finish up. Then you'll be just fine.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
 
Z

ZQ

That's the info I needed.
Thanks, Kevin


Kevin Spencer said:
Not necessarily. The Stop event sends a message to the service application
to stop. It doesn't kill the thread. That's why there's an event handler
there. But make sure that you account for the Stop event, and don't take
too long to finish up. Then you'll be just fine.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
We got a sick zebra a hat,
you ultimate tuna.
 

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