I have a windows service that when started creates two threads: one thread
that runs a TcpListener waiting for TcpClients to connect, and another
thread that reads from the resulting sockets. My stop code .Abort()s the
threads and .Stop()s the listener.
One one of my computers, the service runs like, well...a service. It starts
and stops nicely. On a different computer (eventually this service will be
running on 50+ machines) the service starts up fine, but when you stop it it
seems to hang. Services.mmc reports "Stopping". The very first line in my
Stop() method writes to the Event Log, but that line is never getting
executed (no log entry appears).
Most often, it stays in "Stopping" until I kill the process via the task
manager. When I do this, subsequent attempts to Start result in
Services.mmc telling me "The service on Local Computer started and the
stopped. Some services stop automatically if they have no work to do..."
I'd say its something to do with my shutdown, like me trying to abort the
threads and them not cooperating, but like I say it works fine on one PC but
not another.
steve - 23 Aug 2005 23:31 GMT
Worse case scenario, you could install vs.net on this computer and
debug the onstop method to see where it's hanging.
John Bailo - 23 Aug 2005 23:56 GMT
Do you do something like a Thread.Join to make sure they are all stopped?
Are you using any try/catch blocks in the shutdown method to see if any
errors are thrown (and write them to a Trace.Listener text file or event
log) ?
> I have a windows service that when started creates two threads: one thread
> that runs a TcpListener waiting for TcpClients to connect, and another
[quoted text clipped - 16 lines]
> threads and them not cooperating, but like I say it works fine on one PC but
> not another.