Stopping a service thats in a timed loop
Posted on 1998-08-12
I have coded an NT service whose function is to send a data string to a network device on a timed interval. The timed interval is typically set to 30 seconds or more. My problem is that if an NT service takes longer than 3 seconds to shutdown, the Service Control Manager thinks that the service has stopped responding. I am using the sleep() function to wait for the specified interval. If I stop my service from the Services applet in Control Panel while the service is in the sleep state, it typically takes longer than 3 seconds and I get the message, "Service not responding to the control function". I also tried to use SetWaitableTimer( compiled and linked ok ) but the damn thing would not trigger my function to execute.(??) It seems I have to change my program design a bit but what's the best way to do it. Should I be using SetWaitableTimer - I've never used it before so anyone with experience, your input is appreciated?