2

... or .Start() for that matter?

MSDN says nothing about it. There are no relevant google results that touch on this question. Reference source doesn't include the method body for some reason.

In testing it, it's tough to tell because the services that I'm willing to stop all do so very quickly.

EDIT: I'm not asking if it's implementing one of the asynchronous patterns -- it's obviously not; I'm just wondering if it the method sends a request to stop the service but doesn't wait to hear back, much like Process.CloseMainWindow().

rory.ap
  • 34,009
  • 10
  • 83
  • 174
  • But you _can_ see that the methods _do not_ end with `Async`, and that they are voids in Reference Source. Those two indications should be enough, right? – rickvdbosch Jan 10 '18 at 13:07
  • Not all asynchronous methods end in async. I'm not asking if this method implements async-await; it obviously doesn't. – rory.ap Jan 10 '18 at 13:07
  • @RickvandenBosch -- see my answer. – rory.ap Jan 10 '18 at 14:09
  • 1
    Thanks for the update. Sounds plausible that `ServiceController.Stop()` _triggers_ the stop of a service, but doesn't _wait_ for it. Probably commented too fast... :/ – rickvdbosch Jan 10 '18 at 14:14

1 Answers1

3

Okay I was finally able to answer my own question, and the answer is: the call to System.ServiceProcess.ServiceController.Stop() is asynchronous, i.e. control returns immediately while the service itself may take quite a bit longer to actually stop.

I confirmed this by building my own service which, when stopped, waits 20 seconds before completing. The call to Stop(), however, returns right away.

rory.ap
  • 34,009
  • 10
  • 83
  • 174