Question on services and SCM...
-
When you order a service to stop when it's really busy with something and may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? :wtf: Same q for the all other requests.
-
When you order a service to stop when it's really busy with something and may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? :wtf: Same q for the all other requests.
inner wrote: may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? Depends on how you write the service. You must report the status of your service at regular intervals to inform the SCM of your state. When you receive a request to stop, you set the service status to stopping. Then every few seconds you update the SCM and let it know you are still stopping. If the SCM does not receive an update within a reasonable amount of time it will assume you have stopped responding. The same would be true during startup, pause, and continue. Just provide updated every few seconds. If you need to perform a really long operation that cannot be broken down into smaller portions then run that work in a seperate thread. Then in the main thread you wait a limited time for the worker thread to complete. If it does not finish you report your status and then wait again. --
"The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed." -- Abraham Lincoln
-
inner wrote: may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? Depends on how you write the service. You must report the status of your service at regular intervals to inform the SCM of your state. When you receive a request to stop, you set the service status to stopping. Then every few seconds you update the SCM and let it know you are still stopping. If the SCM does not receive an update within a reasonable amount of time it will assume you have stopped responding. The same would be true during startup, pause, and continue. Just provide updated every few seconds. If you need to perform a really long operation that cannot be broken down into smaller portions then run that work in a seperate thread. Then in the main thread you wait a limited time for the worker thread to complete. If it does not finish you report your status and then wait again. --
"The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed." -- Abraham Lincoln
Hmmmm... Ok. I always thought that SCM makes calls to a service and not the other wayt around. How do you send anything back from service to SCM? Even would be a lot better is you know how to do that in C# service. Thanks a lot.
-
inner wrote: may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? Depends on how you write the service. You must report the status of your service at regular intervals to inform the SCM of your state. When you receive a request to stop, you set the service status to stopping. Then every few seconds you update the SCM and let it know you are still stopping. If the SCM does not receive an update within a reasonable amount of time it will assume you have stopped responding. The same would be true during startup, pause, and continue. Just provide updated every few seconds. If you need to perform a really long operation that cannot be broken down into smaller portions then run that work in a seperate thread. Then in the main thread you wait a limited time for the worker thread to complete. If it does not finish you report your status and then wait again. --
"The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed." -- Abraham Lincoln
Also do you know how ro "register" or "re-register" a "source" to "log" for event logging? I keep getting this
"The source 'MyService' is not registered in log 'Application'. (It is registered in log 'MyServiceLog'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property."
exception after I tried to change the log to standard "application". -
Hmmmm... Ok. I always thought that SCM makes calls to a service and not the other wayt around. How do you send anything back from service to SCM? Even would be a lot better is you know how to do that in C# service. Thanks a lot.
Well using C# I am not sure. I've seen C# and that is about it. In C++ using Win32 you would do something like this.
SetServiceStatus(m_tSvcStatusHandle, &m_tSvcStatus);
Do a search on MSDN for SetServiceStatus. SetServiceStatus[^] --"The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed." -- Abraham Lincoln