<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Thu, Feb 4, 2016 at 5:41 PM, Richard Mace <span dir="ltr"><<a href="mailto:richard.mace@gmail.com" target="_blank">richard.mace@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">What's the best way of shutting down a service that is a service, having the same effect as the user clicking stop. </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Basically, I want my service to monitor a condition, which if met, it will stop itself.
</blockquote></span></div></div></div></blockquote><div><br>Microsoft is using a loop waiting for the status to report as STOPPED<br><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms686335%28v=vs.85%29.aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/ms686335%28v=vs.85%29.aspx</a><br><br></div><div>but since you are running the code from within your running service, it may not be considered useful to wait for yourself (as a program) to have completed stop.<br></div></div></div></div>