T
Techno_Dex
What is the proper way to terminate a Thread in a Windows Service? I have a
windows service which starts up three threads which run in a while loop as
long as a boolean flag is set to true. These threads each sleep for X
ammount of time then start processing again. Since this is a service it's
basically running in an infinite loop. When the user goes to stop the
service, I have been calling the Thread.Abort() method, which throws a
ThreadAbortedException. I've also tried using the Thread.Interupt() method
to wake any sleeping threads, but that too throws a
ThreadInteruptedException. What is the proper way to kill these threads in
the 30 second timeframe that the windows service framework gives a service
to respond back? If catching these Exceptions are the correct way to stop
the service, what is the correct way to know if the service actually dies on
it's own for some reaon (i.e. god forbid locking)?
windows service which starts up three threads which run in a while loop as
long as a boolean flag is set to true. These threads each sleep for X
ammount of time then start processing again. Since this is a service it's
basically running in an infinite loop. When the user goes to stop the
service, I have been calling the Thread.Abort() method, which throws a
ThreadAbortedException. I've also tried using the Thread.Interupt() method
to wake any sleeping threads, but that too throws a
ThreadInteruptedException. What is the proper way to kill these threads in
the 30 second timeframe that the windows service framework gives a service
to respond back? If catching these Exceptions are the correct way to stop
the service, what is the correct way to know if the service actually dies on
it's own for some reaon (i.e. god forbid locking)?