|
| Iniciado por guest, 06,nov. 2014 11:10 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 06,noviembre 2014 - 11:10 |
Hi,
I have a service running to perform background tasks on a server. Like sending a batch of emails. I'm wondering how a WD service responds on a service-stop, let say when the server is going to reboot. This task can run for say a minute or so, processing hundred emails.
Suppose my email-task is running at that very moment. Would the service just "kill" the mail-task? Or wait for it to finish? Or do I have to check every loop for some kind of "service will stop" signal? Or should I take shorten the loop to lets say max 10 seconds or so? |
| |
| |
| | | |
|
| | |
| |
| Publicado el 06,noviembre 2014 - 18:21 |
Hi Arie Quote Arie Mars
Hi,
I have a service running to perform background tasks on a server. Like sending a batch of emails.
I'm wondering how a WD service responds on a service-stop, let say when the server is going to reboot.
This task can run for say a minute or so, processing hundred emails.
Suppose my email-task is running at that very moment. Would the service just "kill" the mail-task? Or wait for it to finish?
Or do I have to check every loop for some kind of "service will stop" signal?
Or should I take shorten the loop to lets say max 10 seconds or so?
If your service program is processing, the service stop request from windows will probably timeout, it usually does from a manual requets. However, there may be something in the windows shutdown to end tasks after a while.
What you should do is process tasks in batches and check a for a stop request at regular intervals.
Check the state of a processing flag within the loop after each task or small batch of tasks This flag can be set to stop within the service projects' "stopping the service" event/procedure.
Remember, to allow another operation (in this case the service manager), to interact with you application, you will need to allow for a small wait state, just as you would in a ui if you have a cancel button in a looping process. See ServiceWait()
Cheers
Malc |
| |
| |
| | | |
|
| | |
| |
| Publicado el 07,noviembre 2014 - 09:40 |
| Thanks Malc, looks pretty straight forward |
| |
| |
| | | |
|
| | | | |
| | |
|