Hi,
I'm trying to write a service in C#. I've got it running and installed, but I have two questions...
1. When the SCM starts and stops a service, does it always start and stop an entire process and CLR? Or might it keep the Service object in memory, and call OnStart() multiple times on the same object if you restart the service.
2. I can't find docs that explain what exactly happens around the call to OnStop(). Specifically, does it have to run in a certain amount of time? And after OnStop returns, are threads in the service allowed to finish gracefully and cleanup, or is the SCM going to kill them? I ask because let's imagine I have a mail server, and a client might be in the middle of uploading a 5 MB email. I would like the worker thread handling that interaction to shutdown gracefully. Is there a way to do that?
thanks,
Rob
I'm trying to write a service in C#. I've got it running and installed, but I have two questions...
1. When the SCM starts and stops a service, does it always start and stop an entire process and CLR? Or might it keep the Service object in memory, and call OnStart() multiple times on the same object if you restart the service.
2. I can't find docs that explain what exactly happens around the call to OnStop(). Specifically, does it have to run in a certain amount of time? And after OnStop returns, are threads in the service allowed to finish gracefully and cleanup, or is the SCM going to kill them? I ask because let's imagine I have a mail server, and a client might be in the middle of uploading a 5 MB email. I would like the worker thread handling that interaction to shutdown gracefully. Is there a way to do that?
thanks,
Rob