/// <summary> /// <para> /// Stops the service if it's not already stopped. This is intended to be called by /// external things like unit test fixtures and is not intended to be called by the /// service itself. /// </para> /// </summary> /// <exception cref="TimeoutException"> /// Thrown if the service did not exit gracefully in time before it would have /// been killed (e.g. by Kubernetes or Docker). /// </exception> /// <remarks> /// <note> /// It is not possible to restart a service after it's been stopped. /// </note> /// <para> /// This is intended for internal use or managing unit test execution and is not intended /// for use by the service to stop itself. /// </para> /// </remarks> public virtual void Stop() { lock (syncLock) { if (stopPending || !isRunning) { return; } stopPending = true; } Terminator.Signal(); }