Stopping windows stops, but the process continues

I am developing a Windows Service application and I notice an unusual problem. First, I start the service from the Windows Services window and wait until the status goes to "Start". After a few minutes, I hit the Stop button and the service status goes blank after 20 seconds or so, indicating that the service has stopped. However, the process behind these services continues to run and can be seen in the Task Manager for 10-30 seconds after the status update. I am working on Windows 7sp1. I also checked Event Viewer and it doesn't show any errors from my service. (The reason I mention this is because I initially suspected a timeout error of the form "Timeout was reached while waiting for a transaction response from service x".)

Any ideas that might be causing the inconsistency between process state and service state?

+3


source to share


1 answer


This happens when you have other threads still running that are not related (or disconnected) from threads associated with your service.

Note that a process can be multi-user and multiple multiple services, so a stop command does not always mean that the owner process has to exit, just for the service to stop running in the process.



For further debugging, when you encounter this limbo state, you should attach a debugger and stop all threads and check the call stacks in each thread. For a single servicing process, you will most likely find that a thread hangs waiting for I / O or other operations to complete, or that there are idle threads, such as message flow threads, that are waiting for signals that will never be raised.

+6


source







All Articles