![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Windows service thread seems dead I created a Windows service with a worker thread which performs some work every 5 minutes; sleeping in between. Everytime it performs the work, it writes a status to a log file. The service runs fine most of the time, but sometimes it seems to do nothing; the status in Services Manager is "Started", but the log file is no longer updated with a status. All errors are written to the log file and to the Event Log using a try...catch block at the main entry point (main method) and using a UnhandledExceptionEventHandler (initialized upon entering the main method. However, no errors appear in the log file when the status stops getting written. I suspect that the thread is ending abnormally, but the main process is not. I'm not sure what step to take next to ensure this service runs more reliably. Could someone offer some suggestions? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Windows service thread seems dead Quote: > I suspect that the thread is ending abnormally, but the main process is not. > I'm not sure what step to take next to ensure this service runs more > reliably. Could someone offer some suggestions? suspect it's hung. e.g. http://www.microsoft.com/downloads/d...displaylang=en Put some copious logging into your worker thread so you know what it was doing when it stopped. If the problem is repeatable and you find it always stops at the same place it should make things a lot easier to fix. I have to do this occasionally as developers aren't allowed any access to live hosts where I work, so debugging difficult to reproduce problems at arms length becomes second nature. Usually the fix only takes 5% of the time it takes to find the problem. Good luck! |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Windows service thread seems dead On Oct 22, 5:09*pm, Jason Barnett <JasonBarn...@newsgroup> wrote: Quote: > I created a Windows service with a worker thread which performs some work > every 5 minutes; sleeping in between. *Everytime it performs the work, it > writes a status to a log file. *The service runs fine most of the time,but > sometimes it seems to do nothing; the status in Services Manager is > "Started", but the log file is no longer updated with a status. > > All errors are written to the log file and to the Event Log using a > try...catch block at the main entry point (main method) and using a > UnhandledExceptionEventHandler (initialized upon entering the main method.. * > However, no errors appear in the log file when the status stops getting > written. > > I suspect that the thread is ending abnormally, but the main process is not. > *I'm not sure what step to take next to ensure this service runs more > reliably. *Could someone offer some suggestions? computer. In my case I was continually getting XML files which I processed every 5 minutes. During this waiting period I renamed the files and only processed the latest file. However the system would place a lock on the file and if the timing was just right, which happened more that I would have thought, the system would just stop responding. I fixed it by putting the copy in a try catch, sleeping 5 seconds and trying again. I know it's not elegant but I haven't had a problem in the last 5 months. Thought I'd pass it along in case you are doing something similar. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Windows service thread seems dead I already added logging into my worker thread, at it's entry point. However, I revisited the code there and found a potential problem with the code. I found that the thread could complete without error, even though it should continue looping. "Jamesb" wrote: Quote: > Quote: > > I suspect that the thread is ending abnormally, but the main process is not. > > I'm not sure what step to take next to ensure this service runs more > > reliably. Could someone offer some suggestions? > Why not try running a debugging tool against the service when you > suspect it's hung. e.g. > http://www.microsoft.com/downloads/d...displaylang=en > > Put some copious logging into your worker thread so you know what it was > doing when it stopped. If the problem is repeatable and you find it > always stops at the same place it should make things a lot easier to > fix. I have to do this occasionally as developers aren't allowed any > access to live hosts where I work, so debugging difficult to reproduce > problems at arms length becomes second nature. Usually the fix only > takes 5% of the time it takes to find the problem. > > Good luck! > . > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How do the current thread get thread notification of OS intruption | .NET General | |||
| Still Trying to KILL wmplayer.exe DEAD, DEAD, DEAD | Vista General | |||
| Start a new thread from an existing thread, which was started from atimer | .NET General | |||
| DNS service in Vista Home Premium dead after some time | Vista networking & sharing | |||