468,161 Members | 1,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,161 developers. It's quick & easy.

Windows service won't start/stop correctly on one of my test machines...

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.
Aug 23 '05 #1
2 4962
Worse case scenario, you could install vs.net on this computer and
debug the onstop method to see where it's hanging.

Aug 23 '05 #2

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) ?

0to60 wrote:
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.

Aug 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jesper Stocholm | last post: by
2 posts views Thread by Mark | last post: by
3 posts views Thread by mpriem | last post: by
5 posts views Thread by dm3281 | last post: by
1 post views Thread by gcdp | last post: by
reply views Thread by kamranasdasdas | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.