Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Windows service thread seems dead

Reply
 
Old 10-22-2009   #1 (permalink)
Jason Barnett


 
 

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 SpecsSystem Spec
Old 10-23-2009   #2 (permalink)
Jamesb


 
 

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?
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 SpecsSystem Spec
Old 10-25-2009   #3 (permalink)
KellyP


 
 

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?
I had a similar problem that was caused by file locking on the
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 SpecsSystem Spec
Old 10-29-2009   #4 (permalink)
Jason Barnett


 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46