I have an application where it creates some threads for its execution , and one of the thread is run periodically ie it is put into sleep for one hour after running for an iteration ie each one hour it executes and do some work and sleep for another hour
(the period is configurable) an i have created this thread as a BackGroundWorker.
Now My main application is a devloped as a windows service . and When I Stop the service I need to stop all thread in it as well
I am calling cancelAsync for the background worker but since this single thread might be sleeping when this call is made
So I can't make the user wait for an hour for this thread to complete and stop the service (the users might be stopping the windows service for some maintanence or debugging purpose - other wise service will run continously).
So I want to give users the flexibility to kill the background thread if they are stoping the windows service .
ie My aim is to provide a configurable value (in config file ) and based on that value if user try to stop the service it will wait for the background thread to complete itself gracefuly or just kill the thread whatever state it might be Ho do I do
this ? ie Ho do I Kill a background Thread which is in sleep state?
View Complete Post